SignalR 处理 HubConnection
SignalR dispose of HubConnection
在 AspNet SignalR 客户端中,是否需要处理 HubConnection
的操作?
好像需要一些时间,据我所见...
花费太多时间是什么意思?能详细点吗您是否收到超时异常?
摘自《C# 5.0 简述》一书:
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!
如果不是交易破坏者,我会说处置。也可能有助于找出在那里花费这么长时间的原因。
如果是调用Stop()
就没有必要了。
见https://msdn.microsoft.com/en-us/library/dn235890(v=vs.118).aspx
否则,您应该在使用完对象后始终处理 IDisposable
个对象。
如果它花费的时间太长(即阻塞当前线程),只需在 Task
上停止它,例如:
Task.Run(()=>hubConnection.Stop());
在 AspNet SignalR 客户端中,是否需要处理 HubConnection
的操作?
好像需要一些时间,据我所见...
花费太多时间是什么意思?能详细点吗您是否收到超时异常?
摘自《C# 5.0 简述》一书:
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!
如果不是交易破坏者,我会说处置。也可能有助于找出在那里花费这么长时间的原因。
如果是调用Stop()
就没有必要了。
见https://msdn.microsoft.com/en-us/library/dn235890(v=vs.118).aspx
否则,您应该在使用完对象后始终处理 IDisposable
个对象。
如果它花费的时间太长(即阻塞当前线程),只需在 Task
上停止它,例如:
Task.Run(()=>hubConnection.Stop());