VsTaskLibraryHelper::RunAsyncAsVsTask<T> Method (JoinableTaskFactory^, VsTaskRunContext, Func<CancellationToken, Task<T>^>^)

 

Creates an IVsTask to track a cancelable async operation.

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

public:
generic<typename T>
[ExtensionAttribute]
static IVsTask^ RunAsyncAsVsTask(
	JoinableTaskFactory^ joinableTaskFactory,
	VsTaskRunContext priority,
	Func<CancellationToken, Task<T>^>^ asyncMethod
)

Parameters

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

The factory to use for creating the task.

priority
Type: Microsoft.VisualStudio.Shell::VsTaskRunContext

asyncMethod
Type: System::Func<CancellationTokenTask<T>^>^

Return Value

Type: Microsoft.VisualStudio.Shell.Interop::IVsTask^

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

Type Parameters

T

The type of value returned by the async operation.

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: