ThreadHelper ThreadHelper ThreadHelper ThreadHelper ThreadHelper ThreadHelper Class

Definition

Provide a generic dispatcher helper ensure that a method is invoked on the Application's main thread. We use the current Application's Dispatcher for convenient identification of the main thread. Note that this means that the Application's instance must be initialized. Currently, the WindowManager initializes it. However, we don't use DispatcherOperation because they are not RPC friendly. For example, if the UI thread is in the middle of an RPC call, and we need to run code on the UI thread, then DispatcherOperations will not get through. This is because DispatcherOperations are initiated by posting a message to the UI thread and the UI thread needs to dispatch that message. If the UI thread is making an RPC call, these messages will not be removed from the queue. The standard OLE message filter processes only a limited set of messages from the queue and even the Visual Studio message filter ignores most others. By going through the UIThreadInvokerPrivate service, the operation becomes a COM call on the UI thread. This operation will be allowed through our message filter IF it is part of the same logical call - the message filter will see it as a "nested call" and may not reject it.

public ref class ThreadHelper abstract
[Windows::Foundation::Metadata::WebHostHidden]
public ref class ThreadHelper abstract
[Windows::Foundation::Metadata::WebHostHidden]
class ThreadHelper abstract
public abstract class ThreadHelper
type ThreadHelper = class
Public MustInherit Class ThreadHelper
Inheritance
ThreadHelperThreadHelperThreadHelperThreadHelperThreadHelperThreadHelper

Constructors

ThreadHelper() ThreadHelper() ThreadHelper() ThreadHelper() ThreadHelper() ThreadHelper()

Properties

Generic Generic Generic Generic Generic Generic
JoinableTaskContext JoinableTaskContext JoinableTaskContext JoinableTaskContext JoinableTaskContext JoinableTaskContext

Gets the singleton JoinableTaskContext instance for Visual Studio

JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory

Gets the joinable task factory for Visual Studio

Methods

BeginInvoke(Action) BeginInvoke(Action) BeginInvoke(Action) BeginInvoke(Action) BeginInvoke(Action) BeginInvoke(Action)

Schedule an action for execution on the UI thread asynchronously

BeginInvoke(DispatcherPriority, Action) BeginInvoke(DispatcherPriority, Action) BeginInvoke(DispatcherPriority, Action) BeginInvoke(DispatcherPriority, Action) BeginInvoke(DispatcherPriority, Action) BeginInvoke(DispatcherPriority, Action)

Schedule an action for execution on the UI thread asynchronously

CheckAccess() CheckAccess() CheckAccess() CheckAccess() CheckAccess() CheckAccess()

Determines if the call is being made on the UI thread.

GetInvocationWrapper() GetInvocationWrapper() GetInvocationWrapper() GetInvocationWrapper() GetInvocationWrapper() GetInvocationWrapper()

Derived classes must implement the GetInvocationWrapper method to implement a a disposable object that will wrap the called method. This may be null.

Invoke(Action) Invoke(Action) Invoke(Action) Invoke(Action) Invoke(Action) Invoke(Action)

Call an action on the UI thread. If the caller is already on the UI thread then the call is made directly. Otherwise, the call is transferred onto the UI thread and this thread blocks until the call returns. If the UI thread throws an exception, that exception is transferred and rethrown on this thread.

Invoke<TResult>(Func<TResult>) Invoke<TResult>(Func<TResult>) Invoke<TResult>(Func<TResult>) Invoke<TResult>(Func<TResult>) Invoke<TResult>(Func<TResult>) Invoke<TResult>(Func<TResult>)

Evaluate a function on the UI thread. If the caller is already on the UI thread then the call is made directly. Otherwise, the call is transferred onto the UI thread and this thread blocks until the call returns. If the UI thread throws an exception, that exception is transferred and rethrown on this thread.

InvokeAsync(Action, Func<Boolean>) InvokeAsync(Action, Func<Boolean>) InvokeAsync(Action, Func<Boolean>) InvokeAsync(Action, Func<Boolean>) InvokeAsync(Action, Func<Boolean>) InvokeAsync(Action, Func<Boolean>)

Makes the RPC call to invoke the action like Invoke(Action) method but in background thread. Since it is on background thread it doesn't block till the RPC call is served. If the RPC call fails, it retries till the onRpcCallFailed returns true. This method is also different from the BeginInvoke(Action) which uses UI thread dispatcher and it may not be in a state to process the request immediately (i.e. it can be in a pumping wait).

ThrowIfNotOnUIThread(String) ThrowIfNotOnUIThread(String) ThrowIfNotOnUIThread(String) ThrowIfNotOnUIThread(String) ThrowIfNotOnUIThread(String) ThrowIfNotOnUIThread(String)

Determines if the call is being made on the UI thread and throws COMException(RPC_E_WRONG_THREAD) if it is NOT.

ThrowIfOnUIThread(String) ThrowIfOnUIThread(String) ThrowIfOnUIThread(String) ThrowIfOnUIThread(String) ThrowIfOnUIThread(String) ThrowIfOnUIThread(String)

Determines if the call is being made on the UI thread and throws COMException(RPC_E_WRONG_THREAD) if it is.

Extension Methods

FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)
IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

Applies to