I know that when you run some method in parallel by calling BeginInvoke() or ThreadPool.QueueUserWorkItem(...) .NET framework is capturing ExecutionContext object that contains Code Access Security information and some other things.
What I want, is to include in ExecutionContext some data that is needed by my parallel method, but must be also captured at the moment of queuing the task.
Problem is that not always I do have control on the code that is creating this parallel task, so I must find a way to store this data before I call this external code. Thats why I thought about ExecutionContext class.
Is there any way to pass some state the parallel task when I'm not always in the control of the code that is splitting the work between threads.
Found it:
CallContext.LogicalSetData(...)
(documentation)
and
CallContext.LogicalGetData(...)
(documentation)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With