Repository navigation
Async Messaging
#1212
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Background
I think it would be great if we could add async versions of the standard messaging methods and interfaces.
Right now, messaging looks something like this:
However, I find that sometimes I want to perform I/O operations or more intense processing after receiving a message. It's natural to put this sort of work in an async method, but that makes the messaging implementation a little clunky. You either have to use
Task.Run()to "fire and forget" the async operation, or useasync void:Proposal
I propose the addition of a new interface:
IAsyncRecipient<T>, and a new method on theWeakReferenceMessengerclass;SendAsync().Similar to the
IRecipientinterface, theIAsyncRecipientinterface would define a single method:Then, the above clunky code could be modified to be more natural:
In addition, it may be useful to consider other "nice to have" features related to async programming, like incorporating
CancellationTokens.All reactions