Skip to content

Instantly share code, notes, and snippets.

@kennykerr
Last active November 30, 2017 14:31
Show Gist options
  • Save kennykerr/fdb696fcb6c01ff9c50b03b5f6beb2fa to your computer and use it in GitHub Desktop.
Save kennykerr/fdb696fcb6c01ff9c50b03b5f6beb2fa to your computer and use it in GitHub Desktop.
How to define a custom delegate for an event in IDL
runtimeclass Events;
[version(1.0), uuid(da38922c-3d3a-404f-8477-de9c104c4f34)]
delegate HRESULT CustomDelegate([in] int value);
[version(1.0), uuid(6ac35d2c-b2cf-4c36-995c-a9c0764636c9), exclusiveto(Events)]
interface IEvents : IInspectable
{
[eventadd] HRESULT CustomEvent([in] CustomDelegate* handler, [out][retval] EventRegistrationToken* cookie);
[eventremove] HRESULT CustomEvent([in] EventRegistrationToken cookie);
};
[version(1.0), activatable(1.0), static(IEventsStatics, 1.0)]
runtimeclass Events
{
[default] interface IEvents;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment