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
selfDispatcherworkActiononErrorAction<Exception>priorityDispatcherPriority
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
selfDispatcherworkActionsurfaceISurfaceonErrorstringpriorityDispatcherPriority
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
selfDispatcherasyncWorkFunc<Task>onErrorAction<Exception>priorityDispatcherPriority
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
selfDispatcherasyncWorkFunc<Task>surfaceISurfaceonErrorstringpriorityDispatcherPriority
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
selfDispatcherworkActionpriorityDispatcherPriority
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.