Reputation: 164
I want to implement silverlight's localmessaging using async await.
Lets say I created a method, ListenTask()
, that returns a message wrapped in a Task using LocalMessageReceiver's Listen
method and Message Received event.
How can I use async await and process messages as I receive them?
Upvotes: 0
Views: 254
Reputation: 7421
James Manning's answer is a good one; however if you did want to use async/await you can certainly use the Dataflow library to accomplish 'streamed' asynchronous message passing quite robustly.
Upvotes: 0
Reputation: 13589
Since you're expecting many messages, not just one, this is likely a better fit for Reactive Extensions - Observable.FromEvent and then subscribe. Task is a good fit for a single future value, IObservable is a good fit for a 'stream' of future values.
With Rx 2.0, you can use await with observables if you wish.
Upvotes: 3