Disabling synchronization context C# with Example



Disabling synchronization context C# with Example

To disable synchronization context you should call the ConfigureAwait method: 
async Task() Foo() 
{ 
await Task.Run(() => Console.WriteLine("Test")); 
} 
. . . 
Foo().ConfigureAwait(false); 
ConfigureAwait provides a means to avoid the default SynchronizationContext capturing behavior; 
passing false for the flowContext parameter prevents the SynchronizationContext from being used to 
resume execution after the await. 
 

Quote from It's All About the SynchronizationContext. 

0 Comment's

Comment Form

Submit Comment