-
Notifications
You must be signed in to change notification settings - Fork 41
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
make AsyncSubscriber with await. #129
Comments
I do like that pattern. Would you want to make a contribution? |
If I will have time soon I would like to do it. But also I don't mind if it will be implemented by someone else :) |
C#8 now provides |
Here is another approach using channels. var channel = Channel.CreateUnbounded<StanMsg>();
using var connection = new StanConnectionFactory().CreateConnection("test-cluster", "test-client");
using var subscription = connection.Subscribe("topic", (sender, args) =>
{
while (!channel.Writer.TryWrite(args.Message));
});
await foreach (var msg in channel.Reader.ReadAllAsync())
{
// do work
} https://devblogs.microsoft.com/dotnet/an-introduction-to-system-threading-channels/ |
I reviewed the
Subscribe
method usages:Subscribe(string subject, StanSubscriptionOptions options, EventHandler<StanMsgHandlerArgs> handler);
I think we can have some kind more improvements. Please see the following code:
The text was updated successfully, but these errors were encountered: