Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case where event source may remove event and any other added events don't fire #997

Merged
merged 7 commits into from
Oct 1, 2021

Conversation

manodasanW
Copy link
Member

@manodasanW manodasanW commented Sep 18, 2021

Checking for any COM references when subscribing events to ensure our registered wrapper handler is still being held by an event source. If there isn't any, we create a new event wrapper delegate to hold onto the event being subscribed. This seems to fix #626 , but there is technically a scenario which this doesn't handle which is if the delegate is being removed as one is being added on another thread. Handling that scenario will require 1-1 mappings which we will need to consider if that becomes a concern.

Also making the check for IWeakReferenceSource in event source caching not throw an InvalidCastException by using an as operator.

Fixes #626

@manodasanW manodasanW merged commit a69a7ed into master Oct 1, 2021
@manodasanW manodasanW deleted the manodasanw/eventrefcount branch October 1, 2021 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Second event handler not called due to cswinrt delegate combining
2 participants