public void Initialize(ApplicationStartupParameters appParameters) { try { if (_queue == null) { _queue = new MessageQueue(DoSend); } CompositionTarget.Rendering += CompositionTargetRendering; _sender = new ServerMessageSender(); _sender.ApplicationStarted += StartApplicationCompleted; _sender.ChannelFaulted += ChannelFaulted; _sender.MessageReceived += OnServerEventReceived; _sender.ChannelOpening += OnChannelOpening; _sender.ChannelOpened += OnChannelOpened; _sender.Intialize(); } catch (Exception ex) { var args = new ServerChannelFaultEventArgs { Error = ex }; ChannelFaulted(this, args); } }
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; } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { _stop = true; if (_service != null) { _service.PollCompleted -= OnGetPendingEventCompleted; _service = null; } if (_pollingThread != null) { lock (_syncLock) Monitor.PulseAll(_syncLock); _pollingThread.Join(500); _pollingThread = null; } _disposed = true; } }
public ServerMessagePoller(ServerMessageSender service) { _service = service; _service.PollCompleted += OnGetPendingEventCompleted; }