public void Dispose() { Disconnect(); if (_reqSocket != null) { _reqSocket.Dispose(); _reqSocket = null; } if (_subSocket != null) { _subSocket.Dispose(); _subSocket = null; } if (_dealerSocket != null) { _dealerSocket.Dispose(); _dealerSocket = null; } if (_heartBeatTimer != null) { _heartBeatTimer.Dispose(); _heartBeatTimer = null; } //The context must be disposed of last! It will hang if the sockets have not been disposed. if (_context != null) { _context.Dispose(); _context = null; } }
/// <summary> /// Disconnect peer mailbox /// No more messages will be sent to peer until connected again /// </summary> public void Disconnect() { m_mailbox.Dispose(); m_mailbox = null; m_endpoint = null; m_connected = false; m_ready = false; }
public void Shutdown() { if (_socket != null) { try { _socket.Close(); } catch (Exception) { } try { _socket.Dispose(); } catch (Exception) { } } _socket = null; _finished = true; _worker.Join(); NetMQConfig.Cleanup(true); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { _disposed = true; //prevent second call to Dispose if (disposing) { if (null != _heartBeatTimer) { _heartBeatTimer.Enable = false; } if (null != _socketPoller) { _socketPoller.Dispose(); } if (null != _sendQueue) { _sendQueue.Dispose(); } if (null != _dealerSocket) { _dealerSocket.Dispose(); } if (null != _clientPoller) { _clientPoller.Dispose(); } if (null != _receiveQueue) { _receiveQueue.Dispose(); } } } }
/// <summary> /// Release any contained resources. /// </summary> /// <param name="disposing">true if managed resources are to be released</param> protected virtual void Dispose(bool disposing) { if (!disposing) { return; } _mailbox?.Dispose(); }
private void ProxyThread() { RouterSocket router = null; DealerSocket dealer = null; try { router = _ctx.CreateRouterSocket(); dealer = _ctx.CreateDealerSocket(); router.Bind(_frontendAddress); switch (_backendCxMode) { case ConnectionMode.Connect: dealer.Connect(_backendAddress); break; case ConnectionMode.Bind: dealer.Bind(_backendAddress); break; } router.Options.Linger = TimeSpan.Zero; dealer.Options.Linger = TimeSpan.Zero; var xproxy = new Proxy(router, dealer, null); xproxy.Start(); } catch (TerminatingException) { } finally { if (router != null) { try { router.Dispose(); } catch (NetMQException) { } } if (dealer != null) { try { dealer.Dispose(); } catch (NetMQException) { } } } }
/// <summary> /// Disconnect peer mailbox /// No more messages will be sent to peer until connected again /// </summary> internal void Disconnect() { if (Connected) { _loggerDelegate?.Invoke($"{nameof(ZyrePeer)}.{nameof(Disconnect)}() disposing mailbox for peer={this}"); _mailbox.Dispose(); _mailbox = null; Endpoint = null; Connected = false; Ready = false; } }
/// <summary> /// If disposing equals true, the method has been called directly or indirectly by a user's code. /// Managed and unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { _subscriberSocket?.Dispose(); _dealerSocket?.Dispose(); } _isDisposed = true; } }
public override Task Stop() { _cancel.Cancel(); _poller.Stop(); _client.Close(); _client.Dispose(); _isConnected.OnCompleted(); _isConnected.Dispose(); return(Task.CompletedTask); }
public void NetMQSender_WithMissingSerializer_ThrowsArgumentNullException() { // Arrange var socket = new DealerSocket(); // Act TestDelegate construct = () => new NetMQSender(socket, null); // Assert Assert.That(construct, Throws.ArgumentNullException); // Cleanup socket.Dispose(); }
public void Stop() { try { _poller.Stop(); _publisherSocket.Disconnect(_publisherAddress); _dealerSocket.Disconnect(_dealerAddress); _poller.Dispose(); _publisherSocket.Dispose(); _dealerSocket.Dispose(); } finally { NetMQConfig.Cleanup(); } }
/// <summary> /// Cleans up resources /// </summary> private void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { TerminateConnection(); if (!(socket is null)) { socket.ReceiveReady -= PendingMessage; socket.Dispose(); } socket = null; } disposedValue = true; } }
private Task Cleanup() { _cancel.Cancel(); if (null != _getMarketState) { _getMarketState.Close(); _getMarketState.Dispose(); } if (null != _getMarketUpdates) { _getMarketUpdates.Close(); _getMarketUpdates.Dispose(); } return(Task.CompletedTask); }
/// <summary> /// Shut down the service and clean up resources. /// </summary> public void Stop() { if (IsRunning) { try { _poller.Stop(); _subscriberSocket.Disconnect(_publisherAddress); _dealerSocket.Disconnect(_dealerAddress); _poller.Dispose(); _subscriberSocket.Dispose(); _dealerSocket.Dispose(); } finally { IsRunning = false; NetMQConfig.Cleanup(); } } }
protected override void Cleanup() { m_clientSocket.Dispose(); }
public override void Dispose() { poller?.Dispose(); dealerSocket?.Dispose(); routerSocket?.Dispose(); }
public void Dispose() { clientSocket?.Disconnect(connectionString); clientSocket?.Dispose(); }
protected override void Cleanup() { m_workerSocket.Dispose(); }
public void Dispose() { _input?.Dispose(); _output?.Dispose(); }
private void DisposeSocket() { try { _socket?.Dispose(); } catch { } }