/// <summary> /// Removes the client from the collection and disposes it. /// </summary> /// <param name="client"></param> protected void Remove(SocketClient client) { using (TimedLock.Lock(_connections)) { _connections.Remove(client); } client.Dispose(); }
/// <summary> /// Removes the client from the collection and disposes it. /// </summary> /// <param name="client"></param> protected void Remove(SocketClient client) { using(TimedLock.Lock(_connections)) { _connections.Remove(client); } client.Dispose(); }
/// <summary> /// Clears and disposes the SocketClient instances within /// this collection in a thread safe manner. /// </summary> /// <exception cref="GU.Threading.LockTimeoutException"> /// Thrown if a lock on the internal list cannot be acquired. /// </exception> public void Clear() { if (this._isDisposed) { throw new ObjectDisposedException(GetType().Name, "This object is disposed."); } Log.Info("Clearing SocketClientCollection."); using (TimedLock.Lock(_connections)) { while (_connections.Count > 0) { SocketClient client = _connections[0] as SocketClient; _connections.RemoveAt(0); client.Dispose(); } } }