VsTaskLibraryHelper::RunAsync Method (JoinableTaskFactory^, VsTaskRunContext, Func<Task^>^)

 

Wraps the invocation of an async method so that it may execute asynchronously, but may potentially be synchronously completed (waited on) in the future.

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

public:
[ExtensionAttribute]
static JoinableTask^ RunAsync(
	JoinableTaskFactory^ joinableTaskFactory,
	VsTaskRunContext priority,
	Func<Task^>^ asyncMethod
)

Parameters

joinableTaskFactory
Type: Microsoft.VisualStudio.Threading::JoinableTaskFactory^

The factory to use for creating the task.

priority
Type: Microsoft.VisualStudio.Shell::VsTaskRunContext

The priority with which to schedule any work on the UI thread, when and if SwitchToMainThreadAsync is called.

asyncMethod
Type: System::Func<Task^>^

The method that, when executed, will begin the async operation.

Return Value

Type: Microsoft.VisualStudio.Threading::JoinableTask^

An object that tracks the completion of the async operation, and allows for later synchronous blocking of the main thread for completion if necessary.

Exceptions thrown by the delegate are captured by the returned JoinableTask. Note that the asyncMethod delegate begins its execution on the caller's thread, and must explicitly call SwitchToMainThreadAsync if the main thread is desired.

Return to top
Show: