This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static AsyncLocal<string> Property { get; set; } = new AsyncLocal<string>(); | |
| Property.Value = "secretValue"; | |
| WaitCallback callback = (object mode) => { | |
| var context = Property.Value ?? "null"; | |
| $"{mode}: {context}".Dump(); | |
| }; | |
| ThreadPool.UnsafeQueueUserWorkItem(callback, "unsafe mode"); | |
| ThreadPool.QueueUserWorkItem(callback, "safe mode"); | |
| Thread.Sleep(1000);//wait for results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #r "nuget:Akka/1.3.13" // this for https://roslynpad.net/ | |
| using Akka.Actor; | |
| class Actor : UntypedActor { | |
| protected override void OnReceive(object message) => | |
| Sender.Tell(Property.Value); | |
| } | |
| static AsyncLocal<string> Property { get; set; } = new AsyncLocal<string>(); |