This documentation is archived and is not being maintained.

JoinableTaskFactory Class

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.

Namespace:  Microsoft.VisualStudio.Threading
Assembly:  Microsoft.VisualStudio.Threading (in Microsoft.VisualStudio.Threading.dll)

type JoinableTaskFactory =  class end

The JoinableTaskFactory type exposes the following members.

  NameDescription
Public methodJoinableTaskFactory(JoinableTaskCollection)Initializes a new instance of JoinableTaskFactory that adds all generated jobs to the specified collection.
Public methodJoinableTaskFactory(JoinableTaskContext)Initializes a new instance of JoinableTaskFactory with the specified owning context.
Top

  NameDescription
Public propertyContextGets the joinable task context to which this factory belongs.
Protected propertyHangDetectionTimeoutGets or sets the time between the last activity on a synchronously-blocking thread and the beginning of data collection about a possible hang.
Protected propertyUnderlyingSynchronizationContextGets the underlying SynchronizationContext that controls the main thread in the host.
Top

  NameDescription
Protected methodAddAdds the specified joinable task to the applicable collection.
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Protected methodOnTransitionedToMainThreadOccurs whenever a joinable task has completed a transition to the main thread.
Protected methodOnTransitioningToMainThreadOccurs when a joinable task has requested a transition to the main thread.
Protected methodPostToUnderlyingSynchronizationContextPosts a callback to the main thread via the underlying dispatcher, or to the threadpool when no dispatcher exists on the main thread.
Public methodRun(Func(Task))Runs the specified asynchronous method.
Public methodRun(T)(Func(Task(T)))Runs the specified asynchronous method.
Public methodRunAsync(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.
Public methodRunAsync(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.
Public methodSwitchToMainThreadAsyncGets an awaitable whose continuations execute on the synchronization context with which this instance was initialized, so that both deadlocks and reentrancy are mitigated.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Protected methodWaitSynchronouslySynchronously 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.
Protected methodWaitSynchronouslyCoreSynchronously blocks the calling thread for the completion of the specified task.
Top

For more complete comments please see JoinableTaskContext.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: