PostSharp6.6//API Reference/Post­Sharp.​Patterns.​Threading Namespace/Dispatcher­Factory Class/Dispatcher­Factory Methods/Dispatcher­Factory.​Get­Dispatcher­For­Current­Context Method

DispatcherFactory.GetDispatcherForCurrentContext Method

Gets an implementation of the IDispatcher interface that is suitable for dispatching to the current context. This method requires that the current thread is associated to a SynchronizationContext or a WPF Dispatcher.

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 6.6.14.0 (6.6.14.0)
Syntax
C#
public static IDispatcher GetDispatcherForCurrentContext()

Return Value

Type: IDispatcher
An implementation of the IDispatcher for the current context, or null if the current thread is not associated with any SynchronizationContext or a WPF Dispatcher.
Remarks

Subsequent calls to this method in the same context will return the same instance.

If this method is invoke in the contact of an actor (see ActorAttribute), this method will return a dispatcher that allows to dispatch to the actor queue.

See Also