JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory JoinableTaskFactory 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
JoinableTaskFactoryJoinableTaskFactoryJoinableTaskFactoryJoinableTaskFactoryJoinableTaskFactory
Derived

Remarks

For more complete comments please see JoinableTaskContext.

Constructors

JoinableTaskFactory(JoinableTaskCollection) JoinableTaskFactory(JoinableTaskCollection) JoinableTaskFactory(JoinableTaskCollection) JoinableTaskFactory(JoinableTaskCollection) JoinableTaskFactory(JoinableTaskCollection)

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

JoinableTaskFactory(JoinableTaskContext) JoinableTaskFactory(JoinableTaskContext) JoinableTaskFactory(JoinableTaskContext) JoinableTaskFactory(JoinableTaskContext) JoinableTaskFactory(JoinableTaskContext)

Initializes a new instance of JoinableTaskFactory with the specified owning context.

Properties

Context Context Context Context Context

Gets the joinable task context to which this factory belongs.

HangDetectionTimeout HangDetectionTimeout HangDetectionTimeout HangDetectionTimeout HangDetectionTimeout

Gets or sets the time between the last activity on a synchronously-blocking thread and the beginning of data collection about a possible hang.

UnderlyingSynchronizationContext UnderlyingSynchronizationContext UnderlyingSynchronizationContext UnderlyingSynchronizationContext UnderlyingSynchronizationContext

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

Methods

Add(JoinableTask) Add(JoinableTask) Add(JoinableTask) Add(JoinableTask) Add(JoinableTask)

Adds the specified joinable task to the applicable collection.

IsWaitingOnLongRunningTask() IsWaitingOnLongRunningTask() IsWaitingOnLongRunningTask() IsWaitingOnLongRunningTask() IsWaitingOnLongRunningTask()

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

OnTransitionedToMainThread(JoinableTask, Boolean) OnTransitionedToMainThread(JoinableTask, Boolean) OnTransitionedToMainThread(JoinableTask, Boolean) OnTransitionedToMainThread(JoinableTask, Boolean) OnTransitionedToMainThread(JoinableTask, Boolean)

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

OnTransitioningToMainThread(JoinableTask) OnTransitioningToMainThread(JoinableTask) OnTransitioningToMainThread(JoinableTask) OnTransitioningToMainThread(JoinableTask) OnTransitioningToMainThread(JoinableTask)

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

PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object) PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object) PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object) PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object) PostToUnderlyingSynchronizationContext(SendOrPostCallback, Object)

Posts a callback to the main thread via the underlying dispatcher, or to the threadpool when no dispatcher exists on the main thread.

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

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

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

Runs the specified asynchronous method.

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

Runs the specified asynchronous method.

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

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

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

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

RunAsync(Func<Task>, JoinableTaskCreationOptions) RunAsync(Func<Task>, JoinableTaskCreationOptions) RunAsync(Func<Task>, JoinableTaskCreationOptions) RunAsync(Func<Task>, JoinableTaskCreationOptions) 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>>) RunAsync<T>(Func<Task<T>>) RunAsync<T>(Func<Task<T>>) RunAsync<T>(Func<Task<T>>) RunAsync<T>(Func<Task<T>>)

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

RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions) RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions) RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions) RunAsync<T>(Func<Task<T>>, JoinableTaskCreationOptions) 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(CancellationToken) SwitchToMainThreadAsync(CancellationToken) SwitchToMainThreadAsync(CancellationToken) SwitchToMainThreadAsync(CancellationToken) SwitchToMainThreadAsync(CancellationToken)

Gets an awaitable whose continuations execute on the synchronization context with which this instance was initialized, so that both deadlocks and reentrancy are mitigated.

WaitSynchronously(Task) WaitSynchronously(Task) WaitSynchronously(Task) WaitSynchronously(Task) 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) WaitSynchronouslyCore(Task) WaitSynchronouslyCore(Task) WaitSynchronouslyCore(Task) WaitSynchronouslyCore(Task)

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

Extension Methods

FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestor<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestor<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>) FindAncestorOrSelf<TElementType>(TElementType, Func<TElementType,TElementType>, Func<TElementType,Boolean>)
FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>) FindAncestorOrSelf<TAncestorType,TElementType>(TElementType, Func<TElementType,TElementType>)
IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>) IsAncestorOf<TElementType>(TElementType, TElementType, Func<TElementType,TElementType>)

Microsoft internal use only.

Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) 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>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) 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>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,CancellationToken,Task>, Nullable<TimeSpan>) 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>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) Run(JoinableTaskFactory, String, String, Func<IProgress<ThreadedWaitDialogProgressData>,Task>, Nullable<TimeSpan>) 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.

RunAsync(JoinableTaskFactory, VsTaskRunContext, Func<Task>) RunAsync(JoinableTaskFactory, VsTaskRunContext, Func<Task>) RunAsync(JoinableTaskFactory, VsTaskRunContext, Func<Task>) RunAsync(JoinableTaskFactory, VsTaskRunContext, Func<Task>) 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>>) RunAsync<T>(JoinableTaskFactory, VsTaskRunContext, Func<Task<T>>) RunAsync<T>(JoinableTaskFactory, VsTaskRunContext, Func<Task<T>>) RunAsync<T>(JoinableTaskFactory, VsTaskRunContext, Func<Task<T>>) 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>>) RunAsyncAsVsTask<T>(JoinableTaskFactory, VsTaskRunContext, Func<CancellationToken,Task<T>>) RunAsyncAsVsTask<T>(JoinableTaskFactory, VsTaskRunContext, Func<CancellationToken,Task<T>>) RunAsyncAsVsTask<T>(JoinableTaskFactory, VsTaskRunContext, Func<CancellationToken,Task<T>>) RunAsyncAsVsTask<T>(JoinableTaskFactory, VsTaskRunContext, Func<CancellationToken,Task<T>>)

Creates an IVsTask to track a cancelable async operation.

StartOnIdle(JoinableTaskFactory, Action, VsTaskRunContext) StartOnIdle(JoinableTaskFactory, Action, VsTaskRunContext) StartOnIdle(JoinableTaskFactory, Action, VsTaskRunContext) StartOnIdle(JoinableTaskFactory, Action, VsTaskRunContext) 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) StartOnIdle(JoinableTaskFactory, Func<Task>, VsTaskRunContext) StartOnIdle(JoinableTaskFactory, Func<Task>, VsTaskRunContext) StartOnIdle(JoinableTaskFactory, Func<Task>, VsTaskRunContext) 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) WithPriority(JoinableTaskFactory, VsTaskRunContext) WithPriority(JoinableTaskFactory, VsTaskRunContext) WithPriority(JoinableTaskFactory, VsTaskRunContext) WithPriority(JoinableTaskFactory, VsTaskRunContext)

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

Applies to

Thread Safety

This type is thread-safe for all members.