protected virtual void Dispose(bool disposing) { if (!_disposed) { if (_queue != null) { _queue.Stop(); if (disposing) { _queue.Dispose(); } _queue = null; } if (_poller != null) { _poller.Dispose(); _poller = null; } if (_sender != null) { _sender.ApplicationStarted -= StartApplicationCompleted; _sender.ChannelFaulted -= ChannelFaulted; _sender.MessageReceived -= OnServerEventReceived; if (disposing) { _sender.Dispose(); } _sender = null; } // outbound thread should shut down after sender is shut down if (_outboundThread != null) { lock (_outboundQueueSync) Monitor.Pulse(_outboundQueueSync); if (_outboundThread.IsAlive) { _outboundThread.Join(500); } _outboundThread = null; } CompositionTarget.Rendering -= CompositionTargetRendering; _disposed = true; } }
private void StopThreads() { if (_queue != null) { _queue.Dispose(); _queue = null; } if (_outboundThread != null) { if (_outboundThread.IsAlive) { _outboundThread.Abort(); _outboundThread.Join(); } _outboundThread = null; } if (_poller != null) { _poller.Dispose(); _poller = null; } }
private void StartPolling() { _poller = new ServerMessagePoller(_sender); _poller.Start(); }