asp.net.netdisposesignalr.clientsignalr-2

SignalR dispose of HubConnection


In a AspNet SignalR client, is it the action to dispose of a HubConnection necessary?

It seems to take some time, from what I have seen...


Solution

  • It's not necessary if you are calling Stop().

    See https://msdn.microsoft.com/en-us/library/dn235890(v=vs.118).aspx

    otherwise, you should always Dispose of IDisposable objects when you are done using them.

    If it is taking too long (i.e., blocking the current thread), just stop it on a Task, something like:

    Task.Run(()=>hubConnection.Stop());