theraot / Theraot

Backporting .NET and more: LINQ expressions in .net 2.0 - nuget Theraot.Core available.
MIT License
158 stars 30 forks source link

Missing System.Threading .AsyncLocal #143

Open NN--- opened 3 years ago

NN--- commented 3 years ago

https://docs.microsoft.com/en-us/dotnet/api/system.threading.asynclocal-1?view=net-5.0

OwnageIsMagic commented 3 years ago

https://blog.stephencleary.com/2013/04/implicit-async-context-asynclocal.html

Similar code will compile targeting .NET 4.0 (with Microsoft.Bcl.Async); however, it will not work correctly (unless it happens to run on .NET 4.5) because the logical call context is not copied at the right time. In that situation, different parts of different async methods will end up sharing the same stack (and overwriting each other’s stack).

NN--- commented 3 years ago

Maybe there is some hack we can do ?:)