private bool WaitUsingEvent(long smtpSessionId, TimeSpan timeout) { PooledEvent pooledEvent = null; if (!this.sessionEvents.TryGetValue(smtpSessionId, out pooledEvent)) { throw new InvalidOperationException("The session event was not able to be retrieved when attempting to wait for a connection."); } return(pooledEvent.WaitHandle.WaitOne(timeout)); }
private void SetSessionEvent(long smtpSessionId) { PooledEvent pooledEvent = null; if (!this.sessionEvents.TryGetValue(smtpSessionId, out pooledEvent)) { throw new InvalidOperationException("The session event was not able to be retrieved when attempting to wake a thread waiting for a connection."); } pooledEvent.WaitHandle.Set(); }
private bool RemoveConnectionTrackingItems(long smtpSessionId) { MailboxDatabaseConnectionManager.ConnectionInfo connectionInfo = null; bool result = this.connections.TryRemove(smtpSessionId, out connectionInfo); PooledEvent value = null; bool flag = this.sessionEvents.TryRemove(smtpSessionId, out value); if (flag) { this.eventPool.Release(value); } return(result); }