Freigeben über


ThreadHelper.ThrowIfNotOnUIThread(String) Method

Definition

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

 static void ThrowIfNotOnUIThread(std::wstring const & callerMemberName = "");
public static void ThrowIfNotOnUIThread (string callerMemberName = "");
static member ThrowIfNotOnUIThread : string -> unit
Public Shared Sub ThrowIfNotOnUIThread (Optional callerMemberName As String = "")

Parameters

callerMemberName
String

Optional name of caller if a Debug Assert is desired if NOT on the UI thread.

Exceptions

COMException

Thrown with RPC_E_WRONG_THREAD when called on any thread other than the main UI thread.

Remarks

The exception thrown from this method is not expected to be caught and handled by anyone. It is meant to cause the caller to fail, and get their attention that they should be invoking the throwing code on the UI thread. This is analogous to throwing ArgumentException when the caller simply did not understand the contract of the method they were calling.

Applies to