CallContext - What are the recommendations for using this direction?

Does anyone know if there is planned support in future versions of .NET for storing objects in the context of external execution? There is a definite need for it, as shown on the following pages:

CallContext Limitations: https://connect.microsoft.com/VisualStudio/feedback/details/276325/provide-better-context-support-to-async-operations

Implicit vs Explicit Context: http://msmvps.com/blogs/jon_skeet/archive/2010/11/08/the-importance-of-context-and-a-question-of-explicitness.aspx

Types of objects that can be added to the context of the surrounding execution:

  • Those that are not suitable for DI. That is, external dependencies, which should be determined by the client site, but to cross the application area in such a way as to make them inappropriate for passing as arguments to the method. Examples: CancellationToken, IProgress, Transactions, SynchronizationContext, SecurityContext. (In fact, the ExecutionContext was hard-coded to pass the last 2 around ... is there any good reason why an open collection cannot be opened to user code?)
  • Those used by the generic code emitted in the bodies of the methods ... which does not know about the explicit dependencies available to it as arguments in the housing method or properties of its type of declaration. Explore aspects of PostSharp in the AOP world.

It would be great to hear people's thoughts about this :)

EDIT: Also posted a question: http://social.msdn.microsoft.com/Forums/en-US/async/thread/ea21ca57-5340-439c-8ee9-f0185b5787a1

+4
source share

Source: https://habr.com/ru/post/1391718/


All Articles