/// <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; } if (_isRunning) { Stop(); } if (_poller.IsRunning) { _poller?.Stop(); } _poller?.Dispose(); _beacon?.Dispose(); _inbox?.Dispose(); _outbox?.Dispose(); foreach (var peer in _peers.Values) { peer.Destroy(); } foreach (var group in _peerGroups.Values) { group.Dispose(); } foreach (var group in _ownGroups.Values) { group.Dispose(); } }
/// <summary> /// Stop node discovery and interconnection /// </summary> private void Stop() { if (!_isRunning) { return; } _loggerDelegate?.Invoke($"Stopping {_name} {_uuid.ToShortString6()}. Publishing beacon on port 0. Removing _beacon and _inbox from poller."); // Stop broadcast/listen beacon by broadcasting port 0 PublishBeacon(0); Thread.Sleep(1); // Allow 1 millisecond for beacon to go out _poller.Remove(_beacon); _beacon.ReceiveReady -= OnBeaconReady; _beacon.Unsubscribe(); _beacon.Dispose(); _beacon = null; // Stop polling on inbox _poller.Remove(_inbox); _inbox.ReceiveReady -= OnInboxReady; _inbox.Dispose(); // Tell the application we are stopping var msg = new NetMQMessage(3); msg.Append("STOP"); msg.Append(_uuid.ToByteArray()); msg.Append(_name); _outbox.SendMultipartMessage(msg); _isRunning = false; }
public void Dispose() { if (beaconPoller != null && beaconPoller.IsRunning) { beaconPoller.Stop(); } beaconClient?.Dispose(); }
public void Dispose() { _actor?.Dispose(); _publisher?.Dispose(); _subscriber?.Dispose(); _beacon?.Dispose(); _poll?.Dispose(); _shim?.Dispose(); }
public void Stop() { if (!IsRunning) { return; } this._nodes.Clear(); _poller.Stop(); _beacon.Unsubscribe(); _poller.Remove(_beacon); _poller.Remove(timer); _poller.Dispose(); _poller = null; _beacon.Dispose(); _beacon = null; timer = null; }