JoinableTaskFactory Class

Definition

A factory for starting asynchronous tasks that can mitigate deadlocks when the tasks require the Main thread of an application and the Main thread may itself be blocking on the completion of a task.

public ref class JoinableTaskFactory
[Windows::Foundation::Metadata::WebHostHidden]
class JoinableTaskFactory
public class JoinableTaskFactory
type JoinableTaskFactory = class
Public Class JoinableTaskFactory
Inheritance
JoinableTaskFactory
Derived

Remarks

For more complete comments please see the JoinableTaskContext.

Constructors

JoinableTaskFactory(JoinableTaskCollection)

Initializes a new instance of the JoinableTaskFactory class that adds all generated jobs to the specified collection.

JoinableTaskFactory(JoinableTaskContext)

Initializes a new instance of the JoinableTaskFactory class.

Properties

Context

Gets the joinable task context to which this factory belongs.

HangDetectionTimeout

Gets or sets the timeout after which no activity while synchronously blocking suggests a hang has occurred.

UnderlyingSynchronizationContext

Gets the underlying SynchronizationContext that controls the main thread in the host.

Methods

Add(JoinableTask)

Adds the specified joinable task to the applicable collection.

IsWaitingOnLongRunningTask()

Check whether the current joinableTask is waiting on a long running task.

OnTransitionedToMainThread(JoinableTask, Boolean)

Raised whenever a joinable task has completed a transition to the main thread.

OnTransitioningToMainThread(JoinableTask)

Raised when a joinable task has requested a transition to the main thread.

PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object)

Posts a message to the specified underlying SynchronizationContext for processing when the main thread is freely available.

Run(Func<Task>)

Runs the specified asynchronous method to completion while synchronously blocking the calling thread.

Run(Func<Task>, JoinableTaskCreationOptions)

Runs the specified asynchronous method to completion while synchronously blocking the calling thread.

Run<T>(Func<Task<T>>)

Runs the specified asynchronous method to completion while synchronously blocking the calling thread.

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

Runs the specified asynchronous method to completion while synchronously blocking the calling thread.

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<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.

SwitchToMainThreadAsync(Boolean, CancellationToken)

Gets an awaitable whose continuations execute on the synchronization context that this instance was initialized with, in such a way as to mitigate both deadlocks and reentrancy.

SwitchToMainThreadAsync(CancellationToken)

Gets an awaitable whose continuations execute on the synchronization context that this instance was initialized with, in such a way as to mitigate both deadlocks and reentrancy.

WaitSynchronously(Task)

Synchronously blocks the calling thread for the completion of the specified task. If running on the main thread, any applicable message pump is suppressed while the thread sleeps.

WaitSynchronouslyCore(Task)

Synchronously blocks the calling thread for the completion of the specified task.

Extension Methods

Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till a cancelable, async operation completes. An optionally cancelable wait dialog is displayed if the operation takes too long.

Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. An optionally cancelable wait dialog is displayed if the operation takes too long.

Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. Cancellation is offered to the user.

Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. No cancellation is offered to the user.

Run<T>(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task<T>>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till a cancelable, async operation completes. An optionally cancelable wait dialog is displayed if the operation takes too long.

Run<T>(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task<T>>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. An optionally cancelable wait dialog is displayed if the operation takes too long.

Run<T>(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task<T>>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. Cancellation is offered to the user.

Run<T>(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task<T>>, Nullable<TimeSpan>)

Blocks the calling (UI) thread till an async operation completes. No cancellation is offered to the user.

RunAsync(JoinableTaskFactory, VsTaskRunContext, Func<Task>)

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

RunAsync<T>(JoinableTaskFactory, VsTaskRunContext, Func<Task<T>>)

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

RunAsyncAsVsTask<T>(JoinableTaskFactory, VsTaskRunContext, Func<CancellationToken,Task<T>>)

Creates an IVsTask to track a cancelable async operation.

StartOnIdle(JoinableTaskFactory, Action, VsTaskRunContext)

Schedules a delegate for background execution on the UI thread without inheriting any claim to the UI thread from its caller.

StartOnIdle(JoinableTaskFactory, Func<Task>, VsTaskRunContext)

Schedules a delegate for background execution on the UI thread without inheriting any claim to the UI thread from its caller.

WithPriority(JoinableTaskFactory, VsTaskRunContext)

Creates a JoinableTaskFactory that schedules work with the specified Visual Studio UI thread priority.

WithPriority(JoinableTaskFactory, Dispatcher, DispatcherPriority)

Creates a JoinableTaskFactory that schedules work with the specified Dispatcher and DispatcherPriority.

Applies to

Thread Safety

This type is thread-safe for all members.