Condividi tramite


JoinableTaskFactory.RunAsync Method

Definition

Overloads

RunAsync(Func<Task>)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

RunAsync(Func<Task>, JoinableTaskCreationOptions)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

RunAsync(Func<Task>, String, JoinableTaskCreationOptions)
RunAsync<T>(Func<Task<T>>)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

RunAsync<T>(Func<Task<T>>, String, JoinableTaskCreationOptions)

RunAsync(Func<Task>)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

public:
 Microsoft::VisualStudio::Threading::JoinableTask ^ RunAsync(Func<System::Threading::Tasks::Task ^> ^ asyncMethod);
public Microsoft.VisualStudio.Threading.JoinableTask RunAsync (Func<System.Threading.Tasks.Task> asyncMethod);
member this.RunAsync : Func<System.Threading.Tasks.Task> -> Microsoft.VisualStudio.Threading.JoinableTask
Public Function RunAsync (asyncMethod As Func(Of Task)) As JoinableTask

Parameters

asyncMethod
Func<Task>

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

Returns

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

Remarks

Exceptions thrown by the delegate are captured by the returned JoinableTask.

When the delegate resumes from a yielding await, the default behavior is to resume in its original context as an ordinary async method execution would. For example, if the caller was on the main thread, execution resumes after an await on the main thread; but if it started on a threadpool thread it resumes on a threadpool thread.

Applies to

RunAsync(Func<Task>, JoinableTaskCreationOptions)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

public:
 Microsoft::VisualStudio::Threading::JoinableTask ^ RunAsync(Func<System::Threading::Tasks::Task ^> ^ asyncMethod, Microsoft::VisualStudio::Threading::JoinableTaskCreationOptions creationOptions);
public Microsoft.VisualStudio.Threading.JoinableTask RunAsync (Func<System.Threading.Tasks.Task> asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.RunAsync : Func<System.Threading.Tasks.Task> * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> Microsoft.VisualStudio.Threading.JoinableTask
Public Function RunAsync (asyncMethod As Func(Of Task), creationOptions As JoinableTaskCreationOptions) As JoinableTask

Parameters

asyncMethod
Func<Task>

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

creationOptions
JoinableTaskCreationOptions

The JoinableTaskCreationOptions used to customize the task's behavior.

Returns

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

Remarks

Exceptions thrown by the delegate are captured by the returned JoinableTask.

When the delegate resumes from a yielding await, the default behavior is to resume in its original context as an ordinary async method execution would. For example, if the caller was on the main thread, execution resumes after an await on the main thread; but if it started on a threadpool thread it resumes on a threadpool thread.

Applies to

RunAsync(Func<Task>, String, JoinableTaskCreationOptions)

Microsoft.VisualStudio.Threading.JoinableTaskFactory.RunAsync``1(System.Func{System.Threading.Tasks.Task{``0}},System.Boolean,System.String,Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions)
public Microsoft.VisualStudio.Threading.JoinableTask RunAsync (Func<System.Threading.Tasks.Task> asyncMethod, string? parentToken, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.RunAsync : Func<System.Threading.Tasks.Task> * string * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> Microsoft.VisualStudio.Threading.JoinableTask
Public Function RunAsync (asyncMethod As Func(Of Task), parentToken As String, creationOptions As JoinableTaskCreationOptions) As JoinableTask

Parameters

asyncMethod
Func<Task>
parentToken
String
creationOptions
JoinableTaskCreationOptions

Returns

Applies to

RunAsync<T>(Func<Task<T>>)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

public:
generic <typename T>
 Microsoft::VisualStudio::Threading::JoinableTask<T> ^ RunAsync(Func<System::Threading::Tasks::Task<T> ^> ^ asyncMethod);
public Microsoft.VisualStudio.Threading.JoinableTask<T> RunAsync<T> (Func<System.Threading.Tasks.Task<T>> asyncMethod);
member this.RunAsync : Func<System.Threading.Tasks.Task<'T>> -> Microsoft.VisualStudio.Threading.JoinableTask<'T>
Public Function RunAsync(Of T) (asyncMethod As Func(Of Task(Of T))) As JoinableTask(Of T)

Type Parameters

T

The type of value returned by the asynchronous operation.

Parameters

asyncMethod
Func<Task<T>>

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

Returns

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

Remarks

Exceptions thrown by the delegate are captured by the returned JoinableTask.

When the delegate resumes from a yielding await, the default behavior is to resume in its original context as an ordinary async method execution would. For example, if the caller was on the main thread, execution resumes after an await on the main thread; but if it started on a threadpool thread it resumes on a threadpool thread.

Applies to

RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions)

Invokes an async delegate on the caller's thread, and yields back to the caller when the async method yields. The async delegate is invoked in such a way as to mitigate deadlocks in the event that the async method requires the main thread while the main thread is blocked waiting for the async method's completion.

public:
generic <typename T>
 Microsoft::VisualStudio::Threading::JoinableTask<T> ^ RunAsync(Func<System::Threading::Tasks::Task<T> ^> ^ asyncMethod, Microsoft::VisualStudio::Threading::JoinableTaskCreationOptions creationOptions);
public Microsoft.VisualStudio.Threading.JoinableTask<T> RunAsync<T> (Func<System.Threading.Tasks.Task<T>> asyncMethod, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.RunAsync : Func<System.Threading.Tasks.Task<'T>> * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> Microsoft.VisualStudio.Threading.JoinableTask<'T>
Public Function RunAsync(Of T) (asyncMethod As Func(Of Task(Of T)), creationOptions As JoinableTaskCreationOptions) As JoinableTask(Of T)

Type Parameters

T

The type of value returned by the asynchronous operation.

Parameters

asyncMethod
Func<Task<T>>

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

creationOptions
JoinableTaskCreationOptions

The JoinableTaskCreationOptions used to customize the task's behavior.

Returns

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

Remarks

Exceptions thrown by the delegate are captured by the returned JoinableTask.

When the delegate resumes from a yielding await, the default behavior is to resume in its original context as an ordinary async method execution would. For example, if the caller was on the main thread, execution resumes after an await on the main thread; but if it started on a threadpool thread it resumes on a threadpool thread.

Applies to

RunAsync<T>(Func<Task<T>>, String, JoinableTaskCreationOptions)

Microsoft.VisualStudio.Threading.JoinableTaskFactory.RunAsync``1(System.Func{System.Threading.Tasks.Task{``0}},System.Boolean,System.String,Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions)
public Microsoft.VisualStudio.Threading.JoinableTask<T> RunAsync<T> (Func<System.Threading.Tasks.Task<T>> asyncMethod, string? parentToken, Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions creationOptions);
member this.RunAsync : Func<System.Threading.Tasks.Task<'T>> * string * Microsoft.VisualStudio.Threading.JoinableTaskCreationOptions -> Microsoft.VisualStudio.Threading.JoinableTask<'T>
Public Function RunAsync(Of T) (asyncMethod As Func(Of Task(Of T)), parentToken As String, creationOptions As JoinableTaskCreationOptions) As JoinableTask(Of T)

Type Parameters

T

Parameters

asyncMethod
Func<Task<T>>
parentToken
String
creationOptions
JoinableTaskCreationOptions

Returns

Applies to