SynchronizationContext in C#

A SynchronizationContext allows one thread to communicate with another thread. For example, to update the User Interface thread (UI Thread) from an outside thread you could do something like the following:

private readonly SynchronizationContext _sync = SynchronizationContext.Current; //Current Thread_sync.Send((state) =>{Label1.Text = "Waiting?"; //Change Control properties from outside threadButton1.Enabled = false;}, null); 
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

More From DevX