更新时间:2023-02-27 08:52:20
Take a look at LogicalCallContext. As of .NET 4.5, it supports async scenarios.
先生. Jeffrey Richter :
.NET Framework具有鲜为人知的功能,该功能使您可以将数据与逻辑"执行线程相关联.此功能称为逻辑 调用上下文,它允许数据流向其他线程,AppDomain,甚至流向其他进程中的线程.
The .NET Framework has a little-known facility that allows you to associate data with a "logical" thread-of-execution. This facility is called logical call context and it allows data to flow to other threads, AppDomains, and even to threads in other processes.