Table of Contents

Class DispatcherExtensions

Namespace
System
Assembly
Instagile.WPF.dll
public static class DispatcherExtensions
Inheritance
DispatcherExtensions
Inherited Members

Methods

EnqueueInvoke(Dispatcher, Action, Action<Exception>, DispatcherPriority)

Invokes work on a future dispatcher frame, handling errors with a delegate.

public static void EnqueueInvoke(this Dispatcher self, Action work, Action<Exception> onError, DispatcherPriority priority = DispatcherPriority.Normal)

Parameters

self Dispatcher
work Action
onError Action<Exception>
priority DispatcherPriority

Remarks

Uses InvokeAsync instead of Task.Run + Invoke, which would cause hangs during dispatcher shutdown in tests because it never returns.

EnqueueInvoke(Dispatcher, Action, ISurface, string?, DispatcherPriority)

Invokes work on a future dispatcher frame, handling errors with a notification.

public static void EnqueueInvoke(this Dispatcher self, Action work, ISurface surface, string? onError = null, DispatcherPriority priority = DispatcherPriority.Normal)

Parameters

self Dispatcher
work Action
surface ISurface
onError string
priority DispatcherPriority

Remarks

Uses InvokeAsync instead of Task.Run + Invoke, which would cause hangs during dispatcher shutdown in tests because it never returns.

EnqueueInvoke(Dispatcher, Func<Task>, Action<Exception>, DispatcherPriority)

Invokes work on a future dispatcher frame, handling errors with a delegate.

public static void EnqueueInvoke(this Dispatcher self, Func<Task> asyncWork, Action<Exception> onError, DispatcherPriority priority = DispatcherPriority.Normal)

Parameters

self Dispatcher
asyncWork Func<Task>
onError Action<Exception>
priority DispatcherPriority

Remarks

Uses InvokeAsync instead of Task.Run + Invoke, which would cause hangs during dispatcher shutdown in tests because it never returns.

EnqueueInvoke(Dispatcher, Func<Task>, ISurface, string?, DispatcherPriority)

Invokes work on a future dispatcher frame, handling errors with a notification.

public static void EnqueueInvoke(this Dispatcher self, Func<Task> asyncWork, ISurface surface, string? onError = null, DispatcherPriority priority = DispatcherPriority.Normal)

Parameters

self Dispatcher
asyncWork Func<Task>
surface ISurface
onError string
priority DispatcherPriority

Remarks

Uses InvokeAsync instead of Task.Run + Invoke, which would cause hangs during dispatcher shutdown in tests because it never returns.

SafeInvoke(Dispatcher, Action, DispatcherPriority)

Invokes work on the dispatcher, unless it's shutting down.

public static void SafeInvoke(this Dispatcher self, Action work, DispatcherPriority priority = DispatcherPriority.Normal)

Parameters

self Dispatcher
work Action
priority DispatcherPriority

Remarks

Invoke(Action) blocks forever after shutdown, which can cause hangs. SafeInvoke tries to block until the work completes, but will return early if the dispatcher begins shutting down.