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

Ensure ListenNotifications not returning before it started listening #1140

Open
ramondeklein opened this issue Jul 24, 2024 · 0 comments
Open

Comments

@ramondeklein
Copy link
Contributor

The ListenNotifications is performing two asynchronuous operatations:

  1. Register for the actual registration of the notifications.
  2. Notifcations that are actually coming in.

Because notifications only are coming in after step 1, you need to make sure that this has been completed, before the function returns.

Go doesn't suffer from this problem, because it doesn't expose async to the caller and it probably uses a callback for the notifications. There are several ways to fix this:

  • Use a Go-style approach that implements an async subscribe function that only returns after it actually has subscribed. This function takes an async delegate as a parameter that is invoked whenever a notification is signalled.
  • Use a more traditional C# implementation that returns Task<IObservable> and returns the observable after subscribing to the object. Although mixing async and IObservable is non-typical, it makes sense here.

See also #1130 (comment).

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

No branches or pull requests

1 participant