internal override sealed void Close(BcpSession.Connection closeConnection) { var newCloseConnection = (BcpClient.Connection)closeConnection; var connectionSize = connections.Count; if (newCloseConnection.busyTimer != null) { newCloseConnection.busyTimer.Change(Timeout.Infinite, Timeout.Infinite); newCloseConnection.busyTimer.Dispose(); newCloseConnection.busyTimer = null; } var isConnectionAllClosed = true; foreach (var connection in connections.Values) { if (!(connection == closeConnection || connection.stream == null)) { isConnectionAllClosed = false; break; } } if (isConnectionAllClosed && connectionSize < Bcp.MaxConnectionsPerSession) { StartReconnectTimer(); } if (connectionSize >= Bcp.MaxConnectionsPerSession && isConnectionAllClosed) { InternalInterrupt(); } }
internal override sealed void Idle(BcpSession.Connection idleConnection) { var newIdleConnection = (BcpClient.Connection)idleConnection; if (newIdleConnection.busyTimer != null) { newIdleConnection.busyTimer.Change(Timeout.Infinite, Timeout.Infinite); newIdleConnection.busyTimer.Dispose(); newIdleConnection.busyTimer = null; } newIdleConnection.connectionState = Bcp.ConnectionState.ConnectionIdle; CheckFinishConnection(); }
internal override sealed void Busy(BcpSession.Connection busyConnection) { var newBusyConnection = (BcpClient.Connection)busyConnection; if (reconnectTimer != null) { reconnectTimer.Change(Timeout.Infinite, Timeout.Infinite); reconnectTimer.Dispose(); reconnectTimer = null; } newBusyConnection.connectionState = Bcp.ConnectionState.ConnectionBusy; var oldBusyTimer = newBusyConnection.busyTimer; if (oldBusyTimer == null) { var newBusyTimer = new Timer(BusyEvent, busyConnection, Bcp.BusyTimeoutMilliseconds, Bcp.BusyTimeoutMilliseconds); newBusyConnection.busyTimer = newBusyTimer; bool isExistIdleConnection = false; foreach (var connection in connections.Values) { var newConnection = (BcpClient.Connection)connection; if (newConnection.stream != null && newConnection.connectionState == Bcp.ConnectionState.ConnectionIdle) { isExistIdleConnection = true; break; } } if (!(connections.Count > 1 && isExistIdleConnection)) { if (idleTimer != null) { idleTimer.Change(Timeout.Infinite, Timeout.Infinite); idleTimer.Dispose(); idleTimer = null; } } } }
internal override sealed void Close(BcpSession.Connection connection) { }
internal override sealed void Busy(BcpSession.Connection connection) { }