質問

How do I override the execution context when creating a new Task object? I want to use one that I previously captured using ExecutionContext.Capture.

役に立ちましたか?

解決

The same as you would when not using TPL: using ExecutionContext.Run(). For example:

Task.Factory.StartNew(
    () => ExecutionContext.Run(
        ec, _ => Console.WriteLine(CallContext.LogicalGetData("foo")), null))
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top