As I’ve started to use MassTransit with SignalR, one of the things that annoyed me was the hoops I had to jump through to get a nice asynchronous request from SignalR into MassTransit. There was a lot of plumbing since the MT did not support the TPL.
Well, I’ve changed that. With version 2.5.3 (a prerelease version on NuGet), you can now get a really nice clean syntax to return tasks from server-side SignalR hubs (and other calls that expect a Task return value.
Shown above is a SignalR hub that sends a request message off to some service. The LocationResult handler that is added within the closure returns a Task
If the request times out, the task for the handler will be cancelled, so be sure to take that into account.
Pretty power stuff eh?
Oh, here’s a demo of how to use it with SignalR: SignalRMassTransitTPLDemo.zip