4

I would like to be able to do something like this:

IHubProxy myHubProxy = /* ... */;

var t1 = Task.Run(() => myHubProxy.Invoke<int>("Foo");
var t2 = Task.Run(() => myHubProxy.Invoke<int>("Foo");

var r1 = await t1;
var r2 = await t2;

Where "Foo" is executed in parallel on the server. However, the way things work by default I believe both of the calls will be synchronized to the hub's thread context and run one by one. Is there any simple way to have a single hubProxy schedule two parallel invocations on the same SignalR hubproxy/connection?

ronag
  • 49,529
  • 25
  • 126
  • 221

1 Answers1

8

You can't send messages in parallel because a transport like webSockets uses the same connection the whole time, you would be trying to interleave messages and it can't be handled. If you need multiple transfers in parallel, then use multiple connections

Gustavo Armenta
  • 1,525
  • 12
  • 14
  • 2
    I guess the underlying network connection doesn't care if messages are interleaved, and that what matters is the protocol that uses the connection. Instead of `Question 1 Reply1 Question 2 Reply2`, how do you know that the SignalR client can't support `Question1 Question2 Reply1 Reply2`? – ChrisW Aug 11 '16 at 21:00