Table of Contents

Class NonConcurrentSynchronizationContext

Namespace
Microsoft.VisualStudio.Threading
Assembly
Microsoft.VisualStudio.Threading.dll

A SynchronizationContext that executes messages in the order they are received.

public sealed class NonConcurrentSynchronizationContext : SynchronizationContext
Inheritance
NonConcurrentSynchronizationContext
Inherited Members
Extension Methods

Remarks

Delegates will be invoked in the order they are received on the threadpool. No two delegates will ever be executed concurrently, but Send(SendOrPostCallback, object?) may permit a delegate to execute inline on another. Note that if the delegate invokes an async method, the delegate formally ends when the async method yields for the first time or returns, whichever comes first. Once that delegate returns the next delegate can be executed.

Constructors

NonConcurrentSynchronizationContext(bool)

Initializes a new instance of the NonConcurrentSynchronizationContext class.

public NonConcurrentSynchronizationContext(bool sticky)

Parameters

sticky bool

A value indicating whether to set this instance as Current when invoking delegates. This has the effect that async methods that are invoked on this SynchronizationContext will execute their continuations on this SynchronizationContext as well unless they use ConfigureAwait(bool) with false as the argument.

Methods

CreateCopy()

public override SynchronizationContext CreateCopy()

Returns

SynchronizationContext

Post(SendOrPostCallback, object?)

public override void Post(SendOrPostCallback d, object? state)

Parameters

d SendOrPostCallback
state object

Send(SendOrPostCallback, object?)

public override void Send(SendOrPostCallback d, object? state)

Parameters

d SendOrPostCallback
state object

Events

UnhandledException

Occurs when posted work throws an unhandled exception.

public event EventHandler<Exception>? UnhandledException

Event Type

EventHandler<Exception>

Remarks

Any exception thrown from this handler will crash the process.