} // LinkState private void ProtocolStateChange(EProtocolStates enmNewState) { // This function is called to change the state of the protocol... Globals.queStatusDisplay.Enqueue(enmNewState.ToString()); if (ProtocolState != enmNewState) { ProtocolState = enmNewState; var switchExpr = ProtocolState; switch (switchExpr) { case EProtocolStates.Disconnected: { if (objB2Protocol != null) { objB2Protocol.Close(); objB2Protocol = null; } break; } case EProtocolStates.Connected: { if (objB2Protocol != null) { objB2Protocol = null; } GetPendingOutboundMessages(); break; } } } } // NewState
} // ProtocolCommands private void Disconnect() { ProtocolState = EProtocolStates.Disconnecting; tmrDisconnect = new System.Timers.Timer(); tmrDisconnect.Elapsed += OnDisconnectTimer; tmrDisconnect.AutoReset = false; tmrDisconnect.Interval = 2000; tmrDisconnect.Enabled = true; } // Disconnect