Class CompoundAsyncEvent<TData>
Base class for compound asynchronous events that carry both strongly-typed business data and cross-handler communication state.
public abstract class CompoundAsyncEvent<TData> : AsyncEvent<TData>, IAsyncEvent, IEventState where TData : class, new()
Type Parameters
TDataThe type containing the event's business data.
- Inheritance
-
objectAsyncEvent<TData>CompoundAsyncEvent<TData>
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Use this base class for compound events (before/after pairs) that need to share state between different event handlers through the State property.
The Data property contains the event's business data, while the State property enables cross-handler communication such as passing data from before-event handlers to after-event handlers.
For simple after-only events that don't need cross-handler state sharing, use AsyncEvent<TData> instead.
Constructors
CompoundAsyncEvent()
Initializes a new instance of the CompoundAsyncEvent<TData> class.
protected CompoundAsyncEvent()
Remarks
This constructor should be used only in testing scenarios.
CompoundAsyncEvent(TData)
Initializes a new instance of the CompoundAsyncEvent<TData> class with the specified properties.
protected CompoundAsyncEvent(TData data)
Parameters
dataTDataThe event's business data. Cannot be null.
CompoundAsyncEvent(TData, EventStateStore)
Initializes a new instance of the CompoundAsyncEvent<TData> class with the specified properties and shared state.
protected CompoundAsyncEvent(TData data, EventStateStore state)
Parameters
dataTDataThe event's business data. Cannot be null.
stateEventStateStoreThe shared state store from a related event (e.g., from a before-event).
Remarks
This constructor is typically used when creating an after-event that needs to share the same state as its corresponding before-event.
Properties
State
Gets the state store for cross-handler communication.
public EventStateStore State { get; }
Property Value
Remarks
Use the state to pass data between event processing handlers when the event is a compound event consisting of multiple associated events (such as before and after events).
For example, a before-event handler can store data that an after-event handler retrieves, enabling coordination between handlers without modifying the business data in Data.