// retrieve the current synchronization context SynchronizationContext context = SynchronizationContext.Current; // post a message to the current synchronization context context.Post(new SendOrPostCallback((o) => { textBox1.Text = o.ToString(); }), "Hello World!");
// retrieve the synchronization context running the current thread SynchronizationContext context = SynchronizationContext.Current; // post a message to the MVC synchronization context context.Post(new SendOrPostCallback((o) => { ViewBag.Message = o.ToString(); }), "Hello World!");Package Library: The System.Threading.SynchronizationContext class is part of the .NET Core and .NET Framework library, specifically in the System.Threading namespace.