SignalR dispose of HubConnection
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());
What do you mean by it takes too much time? Can you detail? Are you getting timeout exception?
From the book C# 5.0 in a Nutshell:
A safe rule to follow (in nearly all cases) is “if in doubt, dispose.” A disposable object —if it could talk—would say the following:
When you’ve finished with me, let me know. If simply abandoned, I might cause trouble for other object instances, the application domain, the computer, the network, or the database!
I would say dispose if it's not a dealbreaker. Also might be useful to find out what takes so long time there.