Skip to content

Feature: Make winrt::event_token an internal implementation rather than a public interface #45

Description

@YexuanXiao

Returning an event_token from the single‑parameter registration overload exists to support classes that do not implement IWeakReference or it is used to register a delegate in one event and unregister it in another event. However, because event_token itself merely stores an integer, unregistering a delegate via event_token is exception‑unsafe.

Solution:

Add an overload (winrt::auto_revoke_strong, Handler). This new overload returns a Revoker that holds a strong reference to this, making it work with any COM object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementAdjust existing featuresfeatureNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions