Open sandboxFocus
  • TOC

Post­Sharp Documentation

Introduction

Deployment and Configuration

Adding Aspects to Code

Logging

Contracts

INotify­Property­Changed

Weak Event

XAML

Parent/Child, Visitor and Disposable

Undo/Redo

Caching

Multithreading

Developing Custom Aspects

Validating Architecture

Testing and Debugging

Miscellaneous

API Reference

Post­Sharp

Post­Sharp.​Aspects

Post­Sharp.​Aspects.​Advices

Post­Sharp.​Aspects.​Configuration

Post­Sharp.​Aspects.​Dependencies

Post­Sharp.​Aspects.​Internals

Post­Sharp.​Aspects.​Serialization

Post­Sharp.​Collections

Post­Sharp.​Constraints

Post­Sharp.​Extensibility

Post­Sharp.​Extensibility.​Build­Time­Logging

Post­Sharp.​Patterns

Post­Sharp.​Patterns.​Caching

Post­Sharp.​Patterns.​Caching.​Backends

Post­Sharp.​Patterns.​Caching.​Backends.​Azure

Post­Sharp.​Patterns.​Caching.​Backends.​Redis

Post­Sharp.​Patterns.​Caching.​Dependencies

Post­Sharp.​Patterns.​Caching.​Formatters

Post­Sharp.​Patterns.​Caching.​Implementation

Post­Sharp.​Patterns.​Caching.​Locking

Post­Sharp.​Patterns.​Caching.​Serializers

Post­Sharp.​Patterns.​Caching.​Value­Adapters

Post­Sharp.​Patterns.​Collections

Post­Sharp.​Patterns.​Collections.​Advices

Post­Sharp.​Patterns.​Contracts

Post­Sharp.​Patterns.​Diagnostics

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Core

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Asp­Net­Framework

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Diagnostic­Source

Post­Sharp.​Patterns.​Diagnostics.​Adapters.​Http­Client

Post­Sharp.​Patterns.​Diagnostics.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Application­Insights

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Audit

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Common­Logging

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Console

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Event­Source

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Log4Net

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Microsoft

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Multiplexer

Post­Sharp.​Patterns.​Diagnostics.​Backends.​NLog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Null

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Serilog

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace

Post­Sharp.​Patterns.​Diagnostics.​Backends.​Trace­Source

Post­Sharp.​Patterns.​Diagnostics.​Contexts

Post­Sharp.​Patterns.​Diagnostics.​Correlation

Post­Sharp.​Patterns.​Diagnostics.​Custom

Post­Sharp.​Patterns.​Diagnostics.​Custom.​Messages

Post­Sharp.​Patterns.​Diagnostics.​Formatters

Post­Sharp.​Patterns.​Diagnostics.​Record­Builders

Post­Sharp.​Patterns.​Diagnostics.​Threading­Instrumentation

Post­Sharp.​Patterns.​Diagnostics.​Transactions

Post­Sharp.​Patterns.​Diagnostics.​Transactions.​Model

Post­Sharp.​Patterns.​Dynamic­Advising

Post­Sharp.​Patterns.​Formatters

Post­Sharp.​Patterns.​Model

Post­Sharp.​Patterns.​Model.​Controls

Post­Sharp.​Patterns.​Model.​Type­Adapters

Post­Sharp.​Patterns.​Recording

Post­Sharp.​Patterns.​Recording.​Operations

Post­Sharp.​Patterns.​Threading

Access­Level­Attribute3

Actor­Attribute8

Actor­Attribute.​Serializer4

Actor­Dispatcher

Ambient­Concurrency­Controller­Context

Assume­Immutable­Attribute2

Background­Attribute6

Concurrency­Controller­Factory

Concurrent­Access­Awaiter

Concurrent­Access­Exception3

Concurrent­Access­Token

Deadlock­Detected­Event­Args2

Deadlock­Detection­Policy5

Deadlock­Detection­Policy.​Serializer2

Deadlocked­Thread­Info

Deadlock­Exception3

Deadlock­Info

Dispatched­Attribute5

Dispatched­Attribute.​Serializer2

Dispatched­Execution­Mode

Dispatcher­Factory

Entry­Point­Attribute3

Explicitly­Synchronized­Attribute3

Freezable­Attribute9

Freezable­Attribute.​Serializer5

IActor

IActor­Controller

IActor­Dispatcher

IConcurrency­Controller

IDispatcher

IDispatcher­Object

IFreezable

IImmutable

Immutable­Attribute9

Immutable­Attribute.​Serializer5

IThread­Aware

Object­Read­Only­Exception2

Private­Thread­Aware­Attribute8

Private­Thread­Aware­Attribute.​Serializer4

Reader­Attribute4

Reader­Writer­Synchronized­Attribute8

Reader­Writer­Synchronized­Attribute.​Serializer4

Read­Only­Thread­Aware­Attribute8

Read­Only­Thread­Aware­Attribute.​Serializer4

Reentrant­Attribute3

Requires­Thread­Safe­Attribute5

Requires­Thread­Safe­Attribute.​Serializer2

Synchronized­Attribute8

Synchronized­Attribute.​Serializer4

Thread­Access­Exception3

Thread­Affine­Attribute8

Thread­Affine­Attribute.​Serializer4

Thread­Aware­Attribute7

Thread­Aware­Attribute.​Serializer3

Thread­Aware­Extensions

Threading­Exception2

Threading­Model

Threading­Patterns­Aspect­Roles

Threading­Services

Threading­Unhandled­Exception­Event­Args2

Threading­Unhandled­Exception­Source

Thread­Mismatch­Exception3

Thread­Safety­Policy5

Thread­Unsafe­Attribute8

Thread­Unsafe­Attribute.​Serializer4

Upgradeable­Reader­Attribute4

Writer­Attribute4

Yielder­Attribute4

Post­Sharp.​Patterns.​Threading.​Models

Post­Sharp.​Patterns.​Utilities

Post­Sharp.​Patterns.​Xaml

Post­Sharp.​Reflection

Post­Sharp.​Reflection.​Method­Body

Post­Sharp.​Serialization

  • Article

Namespace PostSharp.Patterns.Threading

Classes

AccessLevelAttribute

Base class for ReaderAttribute, WriterAttribute, YielderAttributeUpgradeableReaderAttribute.

ActorAttribute

Custom attribute that, when applied to a class, implements the ActorThreadingModel to this class, in which calls to methods are processed asynchronously from a single thread, suppressing concurrency inside each instance of the target class.

ActorAttribute.Serializer

ActorDispatcher

A dispatcher compatible with the ActorThreadingModel threading model, with a message queue based on a ConcurrentQueue The queue itself is processed from the ThreadPool.

AssumeImmutableAttribute

Custom attribute that, when applied to a targetType, means that targetType should be assumed to be immutable. The custom attribute can be applied to a type on assembly level by specifying the Type property using the AssumeImmutableAttribute(Type) constructor.

BackgroundAttribute

Custom attribute that, when applied on a method, causes the method to execute in the background. This aspect can be applied to a method with void or Task return type.

ConcurrencyControllerFactory

Provides methods to create new instances of concurrency controllers.

ConcurrentAccessException

Exception thrown when two threads simultaneously attempt to access a method annotated with the ThreadUnsafeAttribute custom attribute.

DeadlockDetectedEventArgs

Arguments for the DeadlockDetected event.

DeadlockDetectionPolicy

Detects deadlocks occurring because of circular wait conditions.

DeadlockDetectionPolicy.Serializer

DeadlockException

Exception thrown by the DeadlockDetectionPolicy class when a deadlock is detected.

DeadlockInfo

Describes the detected deadlock.

DeadlockedThreadInfo

Described state of thread that was detected to be in a deadlock.

DispatchedAttribute

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

DispatchedAttribute.Serializer

DispatcherFactory

Provides implementations of the IDispatcher interface.

EntryPointAttribute

Custom attribute that, when applied to a private or protected instance method, causes all threading model aspects (derived from ThreadAwareAttribute to introduce runtime generation code.

ExplicitlySynchronizedAttribute

Custom attribute that, when applied to a method or field, specifies that threading model aspects (derived from ThreadAwareAttribute) should ignore all verifications for this field or method.

FreezableAttribute

Custom attribute that, when applied to a class, implements the FreezableThreadingModel to this class. The aspect introduces the IFreezable interface into the target class. After the Freeze() method has been invoked, the object can no longer be modified, and can therefore be safely shared between several threads.

FreezableAttribute.Serializer

ImmutableAttribute

Custom attribute that, when applied to a class, implements the ImmutableThreadingModel to this class. The aspect introduces the IImmutable interface into the target class. Immutable objects cannot be modified after the constructor exits.

ImmutableAttribute.Serializer

ObjectReadOnlyException

Exception thrown by objects that have the FreezableThreadingModel or ImmutableThreadingModel when an attempt is made to modify the object after it has been made read-only.

PrivateThreadAwareAttribute

Custom attribute that, when applied to a class, implement the PrivateThreadingModel into this class, in which the threading model of an object is determined by the parent it is assigned to in a parent-child relationship.

PrivateThreadAwareAttribute.Serializer

ReadOnlyThreadAwareAttribute

Base class for aspects FreezableAttribute and ImmutableAttribute.

ReadOnlyThreadAwareAttribute.Serializer

ReaderAttribute

Custom attribute that, when applied on a method, specifies that the method requires read access to the object.

ReaderWriterSynchronizedAttribute

Custom attribute that, when applied on a class, applies the ReaderWriterSynchronizedThreadingModel model to this class and all derived class. Members of this class must then be annotated with attributes specifying the required access level (ReaderAttribute, WriterAttribute, YielderAttribute or UpgradeableReaderAttribute), otherwise build-time and run-time errors are emitted.

ReaderWriterSynchronizedAttribute.Serializer

ReentrantAttribute

Custom attribute that means that the async method to which it is applied can be safely re-entered on each await statement. In case of lock-based models, it means that the lock is released while awaiting. For the actor model, it means that other methods can be invoked during awaiting.

RequiresThreadSafeAttribute

Custom attribute that, when applied to a field, property or parameter, checks that the assigned object is thread safe. Otherwise, the assignment results in an ArgumentException/

RequiresThreadSafeAttribute.Serializer

SynchronizedAttribute

Custom attribute that, when applied to a class, implements the SynchronizedThreadingModel into this class. In a synchronized object, only a single thread can access the object at a time. If a second thread needs to access the object while it is in used by a first thread, the second thread has to wait until the first thread completes its access.

SynchronizedAttribute.Serializer

ThreadAccessException

Exception thrown when the calling thread does not have access to the object.

ThreadAffineAttribute

Custom attribute that, when applied on a type, ensures the instances of this type can only be accessed by the thread that created the instance. When a different thread accesses instances of this type, a ThreadMismatchException exception is thrown.

ThreadAffineAttribute.Serializer

ThreadAwareAttribute

Base class for all aspects implementing threading models.

ThreadAwareAttribute.Serializer

ThreadAwareExtensions

Provides extension methods to the IThreadAware interface.

ThreadMismatchException

Exception thrown when a thread attempts to access an object that is affined to another thread.

ThreadSafetyPolicy

When applied to an assembly, this policy will check for possible concurrency issues.

ThreadUnsafeAttribute

Custom attribute that, when applied on a type, ensures that only one thread executes in methods of this type. When more than one thread accesses methods of this type, a ConcurrentAccessException exception is thrown.

ThreadUnsafeAttribute.Serializer

ThreadingException

Base class for exceptions thrown by the PostSharp.Patterns.Threading component.

ThreadingModel

Base class for all threading models. Defines properties that describe the characteristics of threading models. All classes derived from ThreadingModel are necessarily singletons.

ThreadingPatternsAspectRoles

Enumerates the aspect roles (for use with AspectRoleDependencyAttribute) used by the PostSharp.Patterns.Threading component.

ThreadingServices

Exposes methods to work with the PostSharp.Patterns.Threading namespace.

ThreadingUnhandledExceptionEventArgs

Arguments of the UnhandledException event.

UpgradeableReaderAttribute

Custom attribute that, when applied on a method, specifies that the method requires read and write access to the object, but other threads are allowed to acquire read (but not write) access to the object until a method with the WriterAttribute custom attribute is executed.

WriterAttribute

Custom attribute that, when applied on a method, specifies that the method requires write access to the object.

YielderAttribute

Custom attribute that, when applied on a method, specifies that the method that currently holds write access to the object (see WriterAttribute) allows other threads to read the object during the execution of the target method. This custom attribute is typically used on methods that raise events that must be processed synchronously by other threads.

Structs

AmbientConcurrencyControllerContext

A disposable cookie returned by WithConcurrencyController(IConcurrencyController).

ConcurrentAccessAwaiter

An awaiter for the AcquireAccessAsync(ObjectAccessLevel) method. The struct implements both the Awaiter and Awaitable contracts.

ConcurrentAccessToken

Token returned by the AcquireAccess(ObjectAccessLevel, ref ConcurrentAccessToken) method. This token is intended to be used in a using block. Consumers of this method must call Complete() on success, and Dispose() on exception.

Interfaces

IActor

Interface implemented by the ActorAttribute aspect.

IActorController

Specific definition of the IConcurrencyController for the ActorThreadingModel.

IActorDispatcher

Augments the IDispatcher interface with an Initialize() method, which is invoked after the actor constructor has been invoked.

IConcurrencyController

Controls access to an entity from possibly several threads.

IDispatcher

Defines the semantics of a facility that executes actions synchronously or asynchronously, possibly on a different thread.

IDispatcherObject

Interface implemented by objects that are whose access to methods is being controlled by a Dispatcher.

IFreezable

Interface implemented by the FreezableAttribute aspect. Defines a Freeze() method.

IImmutable

Interface implemented by the ImmutableAttribute aspect.

IThreadAware

Interface implemented by objects that are aware of concurrency. Access to thread-aware objects is controlled by a concurrency controller (IConcurrencyController). Any aspect implementing a threading model (ThreadAwareObjectAttribute) introduces this interface to the target class and ensures that accesses to this class go through the controller.

Enums

DispatchedExecutionMode

Determines whether the caller of a dispatched method (see DispatchedAttribute) waits for the called method.

ThreadingUnhandledExceptionSource

Enumeration of components that can raise the UnhandledException event.

  • Navigation

In this article

Classes

AccessLevelAttribute

ActorAttribute

ActorAttribute.Serializer

ActorDispatcher

AssumeImmutableAttribute

BackgroundAttribute

ConcurrencyControllerFactory

ConcurrentAccessException

DeadlockDetectedEventArgs

DeadlockDetectionPolicy

DeadlockDetectionPolicy.Serializer

DeadlockException

DeadlockInfo

DeadlockedThreadInfo

DispatchedAttribute

DispatchedAttribute.Serializer

DispatcherFactory

EntryPointAttribute

ExplicitlySynchronizedAttribute

FreezableAttribute

FreezableAttribute.Serializer

ImmutableAttribute

ImmutableAttribute.Serializer

ObjectReadOnlyException

PrivateThreadAwareAttribute

PrivateThreadAwareAttribute.Serializer

ReadOnlyThreadAwareAttribute

ReadOnlyThreadAwareAttribute.Serializer

ReaderAttribute

ReaderWriterSynchronizedAttribute

ReaderWriterSynchronizedAttribute.Serializer

ReentrantAttribute

RequiresThreadSafeAttribute

RequiresThreadSafeAttribute.Serializer

SynchronizedAttribute

SynchronizedAttribute.Serializer

ThreadAccessException

ThreadAffineAttribute

ThreadAffineAttribute.Serializer

ThreadAwareAttribute

ThreadAwareAttribute.Serializer

ThreadAwareExtensions

ThreadMismatchException

ThreadSafetyPolicy

ThreadUnsafeAttribute

ThreadUnsafeAttribute.Serializer

ThreadingException

ThreadingModel

ThreadingPatternsAspectRoles

ThreadingServices

ThreadingUnhandledExceptionEventArgs

UpgradeableReaderAttribute

WriterAttribute

YielderAttribute

Structs

AmbientConcurrencyControllerContext

ConcurrentAccessAwaiter

ConcurrentAccessToken

Interfaces

IActor

IActorController

IActorDispatcher

IConcurrencyController

IDispatcher

IDispatcherObject

IFreezable

IImmutable

IThreadAware

Enums

DispatchedExecutionMode

ThreadingUnhandledExceptionSource