Share via


ThreadHelper.Invoke<TResult> Method (Func<TResult>)

Evaluates a function on the UI thread.

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

'Declaration
Public Function Invoke(Of TResult) ( _
    method As Func(Of TResult) _
) As TResult
public TResult Invoke<TResult>(
    Func<TResult> method
)
public:
generic<typename TResult>
TResult Invoke(
    Func<TResult>^ method
)
member Invoke : 
        method:Func<'TResult> -> 'TResult 
JScript does not support generic types or methods.

Type Parameters

  • TResult
    The type of the function evaluation result.

Parameters

  • method
    Type: System.Func<TResult>

    The method to evaluate on the UI thread.

Return Value

Type: TResult
The result of the given type.

Remarks

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 thrown again on this thread.

.NET Framework Security

See Also

Reference

ThreadHelper Class

Invoke Overload

Microsoft.VisualStudio.Shell Namespace