コード例 #1
0
        public override void Run()
        {
            while (!_isStopped)
            {
                try
                {
                    // Receive the message
                    var receivedMessage = _subscriptionClient.Receive();
                    if (receivedMessage == null)
                    {
                        continue;
                    }

                    var dataChangedEvent = Deserialize.BrokeredMessage(receivedMessage);
                    AddToTableStorage(dataChangedEvent);

                    receivedMessage.Complete();
                }
                catch (MessagingException e)
                {
                    if (!e.IsTransient)
                    {
                        Trace.WriteLine(e.Message);
                        throw;
                    }

                    Thread.Sleep(10000);
                }
                catch (OperationCanceledException e)
                {
                    if (!_isStopped)
                    {
                        Trace.WriteLine(e.Message);
                        throw;
                    }
                }
            }
        }