title: SignalR Core two concurrent calls from same client
body: <p><strong>1 I have a long task (3mn) triggered by a Js client to an Asp.Net Core SignalR Hub</strong></p>
  <p>It works fine :</p>
  <pre><code>public class OptimizerHub : Hub, IOptimizerNotification
  {
      public async Task Optimize(LightingOptimizationInput lightingOptimizationInput)
      {
          LightingOptimizer lightingOptimizer = CreateLightingOptimizer();
          Task t = lightingOptimizer.Optimize(lightingOptimizationInput);
          await t;
      }
  }
  </code></pre>
  <p><strong>2 The server callbacks the client to notify progress, messages, ...</strong></p>
  <pre><code>Clients.Caller.SendAsync(nameof(OnProgress), progress);
  </code></pre>
  <p>It works fine so far.</p>
  <p><strong>3 I want the task to be cancellable with a client call to a Hub method</strong></p>
  <pre><code>public Task Cancel()
  {
      GetContextLightingOptimizer()?.Cancel();
      return Task.FromResult(0);
  }
  </code></pre>
  <p><strong>4 The problem</strong></p>
  <p>When the client makes the call, I see it go to the server in Chrome developer tools detail.
  The call doesn't get to the server before the end long task ends (3mn) !</p>
  <p><strong>5 I have tried many solutions</strong></p>
  <p>Like changing my long task call method, always failing :</p>
  <pre><code>    // Don't wait end of task, fails because the context disappear and can't call back the client :
      // Exception : &quot;Cannot access a disposed object&quot;
      
      public async Task Optimize(LightingOptimizationInput lightingOptimizationInput)
      {
          LightingOptimizer lightingOptimizer = CreateLightingOptimizer();
          Task t = lightingOptimizer.Optimize(lightingOptimizationInput);
      }
  </code></pre>
  <p><strong>6 Possible solutions</strong></p>
  <p>The only solution I imagine right now is the client making an Http call in a Http controller, passing a connection id
  that could make the cancellation.</p>
  <p>That post provides information about a possible solution :
  <a href="https://stackoverflow.com/questions/46904678/call-signalr-core-hub-method-from-controller">Call SignalR Core Hub method from Controller</a></p>
  <p><strong>7 Questions</strong></p>
  <p>Is there a simple way that the client makes a second call to the hub while a first call is being processed ?</p>
  <p>There is also a post giving about concurrent calls :
  <a href="https://stackoverflow.com/questions/18657681/signalr-multiple-concurrent-calls-from-client/18663425">SignalR multiple concurrent calls from client</a></p>
  <p>Should I deduce from the previous post that even if my hub server method can make calls many times to the client, it can't process any other call from the client ?</p>