Class DispatcherSynchronizationContext
- Namespace
- CarinaStudio.Threading
- Assembly
- CarinaStudio.AppBase.Avalonia.dll
Implementation of SynchronizationContext based-on Dispatcher.
public class DispatcherSynchronizationContext : SynchronizationContext
- Inheritance
-
DispatcherSynchronizationContext
- Inherited Members
- Extension Methods
Constructors
DispatcherSynchronizationContext(Dispatcher)
Initialize new DispatcherSynchronizationContext instance.
public DispatcherSynchronizationContext(Dispatcher dispatcher)
Parameters
dispatcherDispatcher
Properties
Dispatcher
Get Dispatcher which is related to this instance.
public Dispatcher Dispatcher { get; }
Property Value
- Dispatcher
UIThread
Get DispatcherSynchronizationContext instance for UI thread with Avalonia.Threading.DispatcherPriority.Normal priority.
public static DispatcherSynchronizationContext UIThread { get; }
Property Value
Methods
CancelDelayed(object)
Cancel posted delayed call-back.
public bool CancelDelayed(object token)
Parameters
tokenobjectToken returned from PostDelayed(SendOrPostCallback, object?, DispatcherPriority, int) or PostDelayed(Action, DispatcherPriority, int).
Returns
- bool
True if call-back cancelled successfully.
Post(Action, DispatcherPriority)
Post action with given priority.
public void Post(Action action, DispatcherPriority priority)
Parameters
actionActionAction.
priorityDispatcherPriorityPriority.
Post(SendOrPostCallback, object?)
When overridden in a derived class, dispatches an asynchronous message to a synchronization context.
public override void Post(SendOrPostCallback d, object? state)
Parameters
dSendOrPostCallbackThe SendOrPostCallback delegate to call.
stateobjectThe object passed to the delegate.
Post(SendOrPostCallback, object?, DispatcherPriority)
Post call-back with given priority.
public void Post(SendOrPostCallback d, object? state, DispatcherPriority priority)
Parameters
dSendOrPostCallbackCall-back.
stateobjectState.
priorityDispatcherPriorityPriority.
PostDelayed(Action, DispatcherPriority, int)
Post delayed call-back.
public object PostDelayed(Action callback, DispatcherPriority priority, int delayMillis)
Parameters
callbackActionCall-back.
priorityDispatcherPriorityPriority.
delayMillisintDelayed time in milliseconds.
Returns
- object
Token of posted delayed call-back.
PostDelayed(SendOrPostCallback, object?, DispatcherPriority, int)
Post delayed call-back.
public object PostDelayed(SendOrPostCallback callback, object? state, DispatcherPriority priority, int delayMillis)
Parameters
callbackSendOrPostCallbackCall-back.
stateobjectCustom state pass to call-back.
priorityDispatcherPriorityPriority.
delayMillisintDelayed time in milliseconds.
Returns
- object
Token of posted delayed call-back.
Send(Action, DispatcherPriority)
Send action with given priority and wait for completion.
public void Send(Action action, DispatcherPriority priority)
Parameters
actionActionAction.
priorityDispatcherPriorityPriority.
Send(SendOrPostCallback, object?)
When overridden in a derived class, dispatches a synchronous message to a synchronization context.
public override void Send(SendOrPostCallback d, object? state)
Parameters
dSendOrPostCallbackThe SendOrPostCallback delegate to call.
stateobjectThe object passed to the delegate.
Exceptions
- NotSupportedException
The method was called in a Windows Store app. The implementation of SynchronizationContext for Windows Store apps does not support the Send(SendOrPostCallback, object) method.
Send(SendOrPostCallback, object?, DispatcherPriority)
Send call-back with given priority and wait for completion.
public void Send(SendOrPostCallback d, object? state, DispatcherPriority priority)
Parameters
dSendOrPostCallbackCall-back.
stateobjectState.
priorityDispatcherPriorityPriority.