Table of Contents

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

dispatcher Dispatcher

Dispatcher.

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

DispatcherSynchronizationContext

DispatcherSynchronizationContext.

Methods

CancelDelayed(object)

Cancel posted delayed call-back.

public bool CancelDelayed(object token)

Parameters

token object

Token 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

action Action

Action.

priority DispatcherPriority

Priority.

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

d SendOrPostCallback

The SendOrPostCallback delegate to call.

state object

The 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

d SendOrPostCallback

Call-back.

state object

State.

priority DispatcherPriority

Priority.

PostDelayed(Action, DispatcherPriority, int)

Post delayed call-back.

public object PostDelayed(Action callback, DispatcherPriority priority, int delayMillis)

Parameters

callback Action

Call-back.

priority DispatcherPriority

Priority.

delayMillis int

Delayed 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

callback SendOrPostCallback

Call-back.

state object

Custom state pass to call-back.

priority DispatcherPriority

Priority.

delayMillis int

Delayed 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

action Action

Action.

priority DispatcherPriority

Priority.

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

d SendOrPostCallback

The SendOrPostCallback delegate to call.

state object

The 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

d SendOrPostCallback

Call-back.

state object

State.

priority DispatcherPriority

Priority.