示例#1
0
        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);
                    }
                }
            }
        }
示例#2
0
        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)
                {
                }
            }
        }
示例#3
0
        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)
                {
                }
            }
        }