Struct SynchronizationContextSwitch
A disposable current SynchronizationContext switch object that reverts the change once it gets disposed.
public readonly struct SynchronizationContextSwitch : IDisposable
- Implements
- Inherited Members
- Extension Methods
Constructors
SynchronizationContextSwitch(SynchronizationContext?)
Creates a new SynchronizationContextSwitch instance.
public SynchronizationContextSwitch(SynchronizationContext? context)
Parameters
context
SynchronizationContextAn optional SynchronizationContext instance to temporarily set as the current context.
Properties
Context
A SynchronizationContext instance activated by this switch.
public SynchronizationContext? Context { get; }
Property Value
PreviousContext
A SynchronizationContext instance that was active before this switch has been created. This context will be set as current once the Dispose() method of this switch gets invoked.
public SynchronizationContext? PreviousContext { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Remarks
Sets PreviousContext as the current synchronization context.