using System; using System.Linq; using System.Collections.Generic; using System.Collections.Concurrent; using System.Reflection; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; var local = new AsyncLocal(); local.Value = "parent"; var gate = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); Task child = Child(); Console.WriteLine($"parent-before:{local.Value}"); gate.SetResult(true); await child; Console.WriteLine($"parent-after:{local.Value}"); async Task Child() { local.Value = "child"; await gate.Task; Console.WriteLine($"child:{local.Value}"); }