PostSharpAPI ReferencePost­Sharp.​Patterns.​ThreadingDispatched­Attribute
Open sandboxFocus

DispatchedAttribute Class

Custom attribute that, when applied on a method, specifies that the method should be executed in UI thread.

Inheritance
DispatchedAttribute
Namespace: PostSharp.Patterns.Threading
Assembly: PostSharp.Patterns.Threading.dll
Syntax
[ProvideAspectRole("Threading")]
[MulticastAttributeUsage]
[AspectRoleDependency]
[AspectRoleDependency]
[AspectRoleDependency]
[Metric("UsedFeatures", "PostSharp.Patterns.Threading.DispatchedMethod")]
[LinesOfCodeAvoided(0)]
[Serializer]
public sealed class DispatchedAttribute : MethodLevelAspect, IMethodLevelAspect, IMethodLevelAspectBuildSemantics, IAspectBuildSemantics, IValidableAnnotation, IAspectProvider, IAspect, IService
Remarks

Execution of the method can be synchronous or asynchronous according to the value of the FireAndForget property.

This aspect can be applied to instance methods of UI controls (WinForms or WPF), or to any class implementing the IDispatcherObject manually.

Constructors

Name Description
DispatchedAttribute()

Initializes a new DispatchedAttribute in blocking mode.

DispatchedAttribute(DispatchedExecutionMode)

Initializes a new DispatchedAttribute and specifies whether the execution mode should be blocking or non-blocking.

DispatchedAttribute(PortableFormatterConstructorContext)
DispatchedAttribute(Boolean)

Initializes a new DispatchedAttribute.

Properties

Name Description
ExecutionMode

When the aspect is applied to a void non-async method, this property determines whether the caller will continue immediately after enqueuing the call to the target method, without waiting for the method to complete. The default value is Blocking.

FireAndForget

When the aspect is applied to a void non-async method, this property determines whether the caller will continue immediately after enqueuing the call to the target method, without waiting for the method to complete. The default value is false.

Methods

Name Description
CompileTimeValidate(MethodBase)

Method invoked at build time to ensure that the aspect has been applied to the right target.

Explicit Interface Implementations

Name Description
IAspectProvider.ProvideAspects(Object)

Provides new aspects.