EventSource Class
Represents a non-agile event. EventSource
member functions add, remove, and invoke event handlers. For agile events, use AgileEventSource.
Syntax
template<typename TDelegateInterface>
class EventSource;
Parameters
TDelegateInterface
The interface to a delegate that represents an event handler.
Members
Public Constructors
Name | Description |
---|---|
EventSource::EventSource | Initializes a new instance of the EventSource class. |
Public Methods
Name | Description |
---|---|
EventSource::Add | Appends the event handler represented by the specified delegate interface to the set of event handlers for the current EventSource object. |
EventSource::GetSize | Retrieves the number of event handlers associated with the current EventSource object. |
EventSource::InvokeAll | Calls each event handler associated with the current EventSource object using the specified argument types and arguments. |
EventSource::Remove | Deletes the event handler represented by the specified event registration token from the set of event handlers associated with the current EventSource object. |
Protected Data Members
Name | Description |
---|---|
EventSource::addRemoveLock_ | Synchronizes access to the targets_ array when adding, removing, or invoking event handlers. |
EventSource::targets_ | An array of one or more event handlers. |
EventSource::targetsPointerLock_ | Synchronizes access to internal data members even while event handlers for this EventSource are being added, removed, or invoked. |
Inheritance Hierarchy
EventSource
Requirements
Header: event.h
Namespace: Microsoft::WRL
EventSource::Add
Appends the event handler represented by the specified delegate interface to the set of event handlers for the current EventSource
object.
HRESULT Add(
_In_ TDelegateInterface* delegateInterface,
_Out_ EventRegistrationToken* token
);
Parameters
delegateInterface
The interface to a delegate object, which represents an event handler.
token
When this operation completes, a handle that represents the event. Use this token as the parameter to the Remove() method to discard the event handler.
Return Value
S_OK if successful; otherwise, an HRESULT that indicates the error.
EventSource::addRemoveLock_
Synchronizes access to the targets_ array when adding, removing, or invoking event handlers.
Wrappers::SRWLock addRemoveLock_;
EventSource::EventSource
Initializes a new instance of the EventSource
class.
EventSource();
EventSource::GetSize
Retrieves the number of event handlers associated with the current EventSource
object.
size_t GetSize() const;
Return Value
The number of event handlers in targets_.
EventSource::InvokeAll
Calls each event handler associated with the current EventSource
object using the specified argument types and arguments.
void InvokeAll();
template <
typename T0
>
void InvokeAll(
T0arg0
);
template <
typename T0,
typename T1
>
void InvokeAll(
T0arg0,
T1arg1
);
template <
typename T0,
typename T1,
typename T2
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2
);
template <
typename T0,
typename T1,
typename T2,
typename T3
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4,
T5arg5
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4,
T5arg5,
T6arg6
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4,
T5arg5,
T6arg6,
T7arg7
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4,
T5arg5,
T6arg6,
T7arg7,
T8arg8
);
template <
typename T0,
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6,
typename T7,
typename T8,
typename T9
>
void InvokeAll(
T0arg0,
T1arg1,
T2arg2,
T3arg3,
T4arg4,
T5arg5,
T6arg6,
T7arg7,
T8arg8,
T9arg9
);
Parameters
T0
The type of the zeroth event handler argument.
T1
The type of the first event handler argument.
T2
The type of the second event handler argument.
T3
The type of the third event handler argument.
T4
The type of the fourth event handler argument.
T5
The type of the fifth event handler argument.
T6
The type of the sixth event handler argument.
T7
The type of the seventh event handler argument.
T8
The type of the eighth event handler argument.
T9
The type of the ninth event handler argument.
arg0
The zeroth event handler argument.
arg1
The first event handler argument.
arg2
The second event handler argument.
arg3
The third event handler argument.
arg4
The fourth event handler argument.
arg5
The fifth event handler argument.
arg6
The sixth event handler argument.
arg7
The seventh event handler argument.
arg8
The eighth event handler argument.
arg9
The ninth event handler argument.
EventSource::Remove
Deletes the event handler represented by the specified event registration token from the set of event handlers associated with the current EventSource
object.
HRESULT Remove(
EventRegistrationToken token
);
Parameters
token
A handle that represents an event handler. This token was returned when the event handler was registered by the Add() method.
Return Value
S_OK if successful; otherwise, an HRESULT that indicates the error.
Remarks
For more information about the EventRegistrationToken
structure, see the Windows::Foundation::EventRegistrationToken Structure topic in the Windows Runtime reference documentation.
EventSource::targets_
An array of one or more event handlers.
ComPtr<Details::EventTargetArray> targets_;
Remarks
When the event that is represented by the current EventSource
object occurs, the event handlers are called.
EventSource::targetsPointerLock_
Synchronizes access to internal data members even while event handlers for this EventSource
are being added, removed, or invoked.
Wrappers::SRWLock targetsPointerLock_;