DispatcherQueue Class

Definition

Manages a prioritized queue on which tasks execute in a serial fashion on a thread.

Equivalent WinUI class: Microsoft.System.DispatcherQueue.

public ref class DispatcherQueue sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DispatcherQueue final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DispatcherQueue
Public NotInheritable Class DispatcherQueue
Inheritance
DispatcherQueue
Attributes

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Remarks

All tasks dispatched to a queue execute on the same thread.

Version history

Windows version SDK version Value added
1903 18362 HasThreadAccess

Properties

HasThreadAccess

Gets a value indicating whether the DispatcherQueue has access to the current thread.

Equivalent WinUI property: Microsoft.System.DispatcherQueue.HasThreadAccess.

Methods

CreateTimer()

Creates a DispatcherQueueTimer on the DispatcherQueue to execute a task periodically after a time interval has elapsed.

Equivalent WinUI method: Microsoft.System.DispatcherQueue.CreateTimer.

GetForCurrentThread()

Gets the DispatcherQueue associated with the current thread.

Equivalent WinUI method: Microsoft.System.DispatcherQueue.GetForCurrentThread.

TryEnqueue(DispatcherQueueHandler)

Adds a task to the DispatcherQueue which will be executed on the thread associated with the DispatcherQueue.

Equivalent WinUI method: Microsoft.System.DispatcherQueue.TryEnqueue.

TryEnqueue(DispatcherQueuePriority, DispatcherQueueHandler)

Adds a task to the DispatcherQueue which will be executed on the thread associated with the DispatcherQueue.

Equivalent WinUI method: Microsoft.System.DispatcherQueue.TryEnqueue.

Events

ShutdownCompleted

Fires after the DispatcherQueue event loop stops which is the last step in the DispatcherQueue shutdown process.

Equivalent WinUI event: Microsoft.System.DispatcherQueue.ShutdownCompleted.

ShutdownStarting

Fires before the dispatcher queue initiates an exit from its event loop.

Equivalent WinUI event: Microsoft.System.DispatcherQueue.ShutdownStarting.

Applies to

See also