Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Threading Namespace / Actor­Dispatcher Class

ActorDispatcher Class

A dispatcher compatible with the ActorThreadingModel threading model, with a message queue based on a ConcurrentQueue The queue itself is processed from the ThreadPool.
Inheritance Hierarchy
System.Object
  PostSharp.Patterns.Threading.ActorDispatcher

Namespace:  PostSharp.Patterns.Threading
Assembly:  PostSharp.Patterns.Threading (in PostSharp.Patterns.Threading.dll) Version: 5.0.38.0 (5.0.38.0)
Syntax
C#
public class ActorDispatcher : IActorDispatcher, 
	IDispatcher

The ActorDispatcher type exposes the following members.

Constructors
  NameDescription
Public methodActorDispatcher
Initializes a new ActorDispatcher.
Methods
  NameDescription
Public methodBeginInvoke
Queues an action for asynchronous execution.
Public methodCheckAccess
Determines whether the current thread has access to the current dispatcher.
Public methodInvoke
Executes an action synchronously.
Protected methodMustYield
Determines whether the ProcessQueue() method should interrupt the processing of the message queue before the queue is empty.
Protected methodOnQueueEmpty
Method invoked when the queue becomes empty. The default implementation does not do anything.
Protected methodProcessQueue
Processes the message queue synchronously.
Protected methodScheduleProcessQueue
Schedules the execution of the ProcessQueue(), typically on a worker thread or in the ThreadPool. The default implementation uses the ThreadPool on platforms that have a thread pool, otherwise it schedules a new Task.
Extension Methods
  NameDescription
Public Extension MethodQueryInterface<T>
Gets the implementation of a specified interface for the specified object.
(Defined by QueryInterfaceExtensions.)
Remarks

This implementation will append every action (as a result of the BeginInvoke(SendOrPostCallback, Object) method) into a ConcurrentQueue. If will then create a work item to process the ConcurrentQueue and schedule the work item to the ThreadPool. The same work item will keep running unless the message queue is empty, then will terminate.

You can use a different scheduling mechanism instead of the ThreadPool by deriving the class and overriding the ScheduleProcessQueue() method.

Note that the Invoke(SendOrPostCallback, Object) method of the IDispatcher interface is not supported, because the ActorThreadingModel does not support synchronous calls.

See Also