using System.Threading.Tasks;
public static void Main()
public static AsyncLocal<string> TestStringAsync = new AsyncLocal<string>();
public static async Task Test1() {
Console.WriteLine($"Test1 default value: {TestStringAsync.Value}");
TestStringAsync.Value = "Value 1";
Console.WriteLine($"Test1 set to: {TestStringAsync.Value}");
Console.WriteLine($"Test1 after calling Test2: {TestStringAsync.Value}");
public static async Task Test2() {
Console.WriteLine($"Test2 before setting value: {TestStringAsync.Value}");
TestStringAsync.Value = "Value 2";
Console.WriteLine($"Test2 after setting value: {TestStringAsync.Value}");
await Task.CompletedTask;