/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { _objectStream.Dispose(); _connection.Dispose(); if (_keepAliveTimer != null) { _keepAliveTimer.Stop(); _keepAliveTimer.Dispose(); _keepAliveTimer = null; } }
/// <summary> /// Performs a graceful shutdown of the digital shelf connection. /// </summary> public void Disconnect() { lock (_syncLock) { if (_messageObjectStream == null) { return; } this.Trace("Closing connection to digital shelf."); base.ResetEventQueue(); if ((_shutdownThreadEvent != null) && (_shutdownThreadEvent.SafeWaitHandle.IsClosed == false)) { _shutdownThreadEvent.Set(); } _shutdownThreadEvent = null; _messageDispatcher.Stop(); _messageObjectStream.Dispose(); _messageObjectStream = null; if (_client.Connected) { try { _client.Client.Shutdown(SocketShutdown.Both); } catch (Exception ex) { this.Error("Shutdown of the connected TCP client failed!", ex); } } _client.Close(); _client = null; } }