每次等待完成"选项"时,是否正在使用ThreadStatic并设置上下文?还有另外一种方法吗?
public async void Test()
{
// This is in Thread 1
Foo foo = new Foo();
Context.context = "context1"; // This is ThreadStatic
string result = await foo.CallAsynx();
// This is most likely Thread 2
Context.context = "context1"; // This might be a different thread and so resetting context
}
Run Code Online (Sandbox Code Playgroud)
如果我不想使用ThreadStatic,现在有另一种方法吗?