/// <summary> /// Initializes a new instance of the <see cref="ZmqMessageServer"/> class. /// </summary> /// <param name="messageReceiver">The message receiver.</param> /// <param name="port">The port.</param> internal ZmqMessageServer(IMessageReceiver messageReceiver, int port) { tokenSource = new CancellationTokenSource(); this.port = port; this.messageReceiver = messageReceiver; context = ZmqContext.Create(); responseQueue = new ZmqResponseQueue(context, port); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool disposing) { if (disposing && !tokenSource.IsCancellationRequested) { tokenSource.Cancel(); tokenSource.Dispose(); } if (disposing && responseQueue != null) { responseQueue.Dispose(); responseQueue = null; } if (disposing && context != null) { context.Dispose(); context = null; } }