private async Task ReceiveQueueMessagesAsync(CancellationToken ct) { while (true) { if (ct.IsCancellationRequested) { break; } try { object msgInfo = msgReceiveQueue.Take(); if (_receiver != null) { _receiver.OnMessage(_client, new ReceivedMessageEventArgs(msgInfo)); } } catch (Exception ex) { if (_feedback != null) { _feedback.OnException(_client, ex); } } } }
private async Task ReceiveMessagesFromQueue(CancellationToken ct) { while (true) { if (ct.IsCancellationRequested) { break; } try { CloudQueueMessage queueMsg = cloudQueue.GetMessage(); if (queueMsg != null && _receiver != null) { object msg = MessageHelper.ToObject(queueMsg.AsString); bool result = _receiver.OnMessage(cloudQueue, new ReceivedMessageEventArgs(msg)); if (result) { cloudQueue.DeleteMessage(queueMsg); } } } catch (Exception ex) { } } }
private static async Task NotifyHubEventAsync(CancellationToken ct) { while (true) { if (ct.IsCancellationRequested) { break; } try { object msg = msgReceiveQueue.Take(); if (msg != null && _receiver != null) { _receiver.OnMessage(eventHubClient, new ReceivedMessageEventArgs(msg)); } } catch (Exception ex) { } } }