当前位置: 首页>>代码示例>>C#>>正文


C# SubscriptionClient.Receive方法代码示例

本文整理汇总了C#中SubscriptionClient.Receive方法的典型用法代码示例。如果您正苦于以下问题:C# SubscriptionClient.Receive方法的具体用法?C# SubscriptionClient.Receive怎么用?C# SubscriptionClient.Receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SubscriptionClient的用法示例。


在下文中一共展示了SubscriptionClient.Receive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReceiveAllMessagesFromSubscription

 static void ReceiveAllMessagesFromSubscription(SubscriptionClient myTopicClient)
 {
     while (true)
     {
         var message = myTopicClient.Receive(TimeSpan.FromSeconds(5));
         if (message != null)
         {
             Console.WriteLine("Message received. Id: {0} Body: {1}", message.MessageId, message.GetBody<string>());
         }
         else
         {
             Console.WriteLine("No more messages");
             return;
         }
     }
 }
开发者ID:sandrapatfer,项目名称:PROMPT11-10-CloudComputing.sandrapatfer,代码行数:16,代码来源:Program.cs

示例2: Run

        public override void Run()
        {
            string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            Client = SubscriptionClient.CreateFromConnectionString(connectionString, TopicName, "OrderProcessingSubscription");
            BrokeredMessage message = null;

            while (!IsStopped)
            {
                try
                {
                    // Receive the message
                    BrokeredMessage receivedMessage = null;
                    receivedMessage = Client.Receive();

                    if (receivedMessage != null)
                    {
                        // Process the message
                        Trace.WriteLine("Processing", receivedMessage.SequenceNumber.ToString());

                        OnlineOrder order = receivedMessage.GetBody<OnlineOrder>    ();
                        Trace.WriteLine(order.Customer + ": " + order.Product, "ProcessingMessage");

                        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;
                    }
                }
            }
        }
开发者ID:henningst,项目名称:AzureServiceBus,代码行数:45,代码来源:WorkerRole.cs

示例3: StartReceivingMessages

        private void StartReceivingMessages(SubscriptionClient client, TextBox textBox)
        {
            var worker = new BackgroundWorker();
            worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                                 {
                                     while (true)
                                     {
                                         var brokeredMessage = client.Receive(TimeSpan.FromSeconds(1));

                                         if (brokeredMessage != null)
                                         {
                                             var twitt = brokeredMessage.GetBody<Twitt>();

                                             textBox.Text += string.Format("<{0}>{1}{2}", twitt.TimeStamp.ToString("dd/MM/yyyy HH:mm"), twitt.Content, Environment.NewLine);
                                         }
                                     }

                                 };
            worker.RunWorkerAsync();
        }
开发者ID:varadzhakov,项目名称:work,代码行数:20,代码来源:Followers.cs


注:本文中的SubscriptionClient.Receive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。