private void RemoveThread(SocketInitiatorThread thread) { lock (sync_) { thread.Join(); threads_.Remove(thread.Session.SessionID); } }
private void RemoveThread(SessionID sessionID) { // We can come in here on the thread being removed, and on another thread too in the case // of dynamic session removal, so make sure we won't deadlock... if (Monitor.TryEnter(sync_)) { SocketInitiatorThread thread = null; if (threads_.TryGetValue(sessionID, out thread)) { try { thread.Join(); } catch { } threads_.Remove(sessionID); } Monitor.Exit(sync_); } }
private void RemoveThread(SessionID sessionID) { // We can come in here on the thread being removed, and on another thread too in the case // of dynamic session removal, so make sure we won't deadlock... // yg?? //if (Monitor.TryEnter(sync_)) if (Monitor.TryEnter(GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable, 3000)) { SocketInitiatorThread thread = null; if (threads_.TryGetValue(sessionID, out thread)) { try { thread.Join(); } catch { } threads_.Remove(sessionID); } Monitor.Exit(GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable); } }