/// <summary> /// Start polling for messages. /// </summary> private void StartPolling() { Task.Run(() => { using (var subSocket = context.CreateSubscriberSocket()) { byte[] buffer = null; subSocket.Options.ReceiveHighWatermark = 1000; subSocket.Connect(SubscriberAddress); subSocket.Subscribe(String.Empty); subSocket.ReceiveReady += (s, a) => { buffer = subSocket.Receive(); if (MessageRecieved != null) { MessageRecieved.Report(buffer.ToObject <Taurus.FeedMux>()); } }; // Poll. poller = new Poller(); poller.AddSocket(subSocket); poller.PollTillCancelled(); token.ThrowIfCancellationRequested(); } }, token).ContinueWith(ant => { pollerCancelled.Set(); }, TaskContinuationOptions.OnlyOnCanceled); }