A type that you can use to declare and implement an event of a specified delegate type. Subscribers pass their event-handling delegates to an event; the event registers those delegates in a collection; then, when it is raised, the event invokes its registered delegates in turn so that subscribers can handle the event. For more info about authoring events, and code examples, see Author events in C++/WinRT.
If you need events internal to your project, and not limited to Windows Runtime types, then use event<winrt::delegate>. For more info, see Parameterized delegates, simple signals, and callbacks within a project.
For more info about handling events, and code examples, see Handle events by using delegates in C++/WinRT.
Syntaxtemplate <typename Delegate>
struct event
Template parameters
typename Delegate
The type of delegate that can register to handle the event.
Minimum supported SDK: Windows SDK version 10.0.17134.0 (Windows 10, version 1803)
Namespace: winrt
Header: %WindowsSdkDir%Include<WindowsTargetPlatformVersion>\cppwinrt\winrt\base.h (included by default)
Member type aliases Alias name Type event::delegate_type A synonym for thetypename Delegate
template parameter. Constructors Member functions Member operators event::event constructor
Initializes a new instance of the event struct.
Syntaxevent();
event::add function
Registers a delegate with the event object.
Syntaxwinrt::event_token add(Delegate const& delegate);
Parameters
delegate
A delegate to register with the event object.
A winrt::event_token that can subsequently be used to revoke the delegate's registration.
event::operator() (function call operator)Invokes all of the event object's registered delegates with the provided arguments.
Syntaxtemplate<typename... Arg>
void operator()(Arg const&... args)
Template parameters
typename... Arg
A variadic template parameter pack containing the types of the parameters that the delegate is passed when it's called.
args
A variable argument list containing the arguments that the delegate is passed when it's called.
Checks whether the event object has any delegates registered with it.
Syntaxexplicit operator bool() const noexcept;
Return value
true
if the event object has any registered delegates, otherwise false
.
Revokes a delegate's registration from the event object.
Syntaxvoid remove(winrt::event_token const token);
Parameters
token
A winrt::event_token that identifies the delegate whose registration to revoke.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4