Export (0) Print
Expand All

Dispatcher.Yield Method (DispatcherPriority)

.NET Framework 4.5

Creates an awaitable object that asynchronously yields control back to the current dispatcher and provides an opportunity for the dispatcher to process other events. The work that occurs when control returns to the code awaiting the result of this method is scheduled with the specified priority.

Namespace:  System.Windows.Threading
Assembly:  WindowsBase (in WindowsBase.dll)

public static DispatcherPriorityAwaitable Yield(
	DispatcherPriority priority
)

Parameters

priority
Type: System.Windows.Threading.DispatcherPriority

The priority at which to schedule the continuation.

Return Value

Type: System.Windows.Threading.DispatcherPriorityAwaitable
An awaitable object that asynchronously yields control back to the current dispatcher and provides an opportunity for the dispatcher to process other events.

This method provides a way for you to temporarily release execution control to the current dispatcher so it can do other work, such as process other events. Use the await, or Await in Visual Basic, operator on the return value to return control to the current dispatcher. Use this method if want to give your app a chance to process events while you app is doing a lot of work on the UI thread. For example, you can use this method in a long-running loop that updates a control.

.NET Framework

Supported in: 4.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft