Update:
Found a similar question .
I want to implement some services following the AmbientContext design pattern for our ASP.NET application.
For example, I want the username (for example, Thread.CurrentPrincipal) to be set once at the very beginning of the request and thread processing between threads when performing asynchronous operations.
Thus, I need to attach the data to the ExecutionContext and then detach it while processing the request.
Unfortunately, I have no idea how to do this.
There is a small hint in the documentation :
Internally, an ExecutionContext stores all the data that is associated with a LogicalCallContext. This allows you to use LogicalCallContext data for distribution when copying and passing an ExecutionContext.
source
share