Dispatcher Class

Summary

Provides services for managing work items on a thread.
Namespace
Avalonia.Threading
Interfaces
Base Types
  • object
graph BT Type-->Base0["object"] Type-.->Interface0["IDispatcher"] click Interface0 "/api/Avalonia.Threading/IDispatcher" Type["Dispatcher"] class Type type-node

Syntax

public class Dispatcher : IDispatcher

Remarks

In Avalonia, there is usually only a single Dispatcher in the application - the one for the UI thread, retrieved via the UIThread property.

Constructors

Properties

Name Value Summary
UIThread Dispatcher
static

Methods

Name Value Summary
CheckAccess() bool
Checks that the current thread is the UI thread.
InvokeAsync(Action, DispatcherPriority) Task
Posts an action that will be invoked on the dispatcher thread.
InvokeAsync(Func<Task>, DispatcherPriority) Task
Queues the specified work to run on the dispatcher thread and returns a proxy for the task returned by function.
InvokeAsync<TResult>(Func<Task<TResult>>, DispatcherPriority) Task<TResult>
Queues the specified work to run on the dispatcher thread and returns a proxy for the task returned by function.
InvokeAsync<TResult>(Func<TResult>, DispatcherPriority) Task<TResult>
Posts a function that will be invoked on the dispatcher thread.
MainLoop(CancellationToken) void
Runs the dispatcher's main loop.
Post(Action, DispatcherPriority) void
Invokes a method on the dispatcher thread.
RunJobs() void
Runs continuations pushed on the loop.
RunJobs(DispatcherPriority) void
Use this method to ensure that more prioritized tasks are executed
VerifyAccess() void
Checks that the current thread is the UI thread and throws if not.