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


C# QueueClient.Close方法代码示例

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


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

示例1: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     lstMensagens.Items.Add("status: Recebendo mensagens...");
     this.Refresh();
     queueClient = QueueClient.Create(QueueName);
     BrokeredMessage message = null;
     while (true)
     {
         try
         {
             message = queueClient.Receive(TimeSpan.FromSeconds(2));
             if (message != null)
             {
                 lstResultado.Items.Add(string.Format("Id: {0}, Body: {1}", message.MessageId, message.GetBody<string>()));
                 message.Complete();
             }
             else break;
         }
         catch (MessagingException error)
         {
             if (!error.IsTransient)
             {
                 lstMensagens.Items.Add("status: " + error.Message);
             }
             else ManipularExcecoes(error);
         }
     }
     queueClient.Close();
 }
开发者ID:lhlima,项目名称:CollaborationProjects,代码行数:29,代码来源:FormMensagem.cs

示例2: SubscribeToBus

        /// <summary>
        /// Subscribes the specified handler to the event bus.
        /// </summary>
        /// <param name="handler">The handler.</param>
        /// <param name="bus">The bus.</param>
        public IDisposable SubscribeToBus(object handler, IEventBus bus)
        {
            queueClient = CreateQueueClient(settings);

            return new CompositeDisposable
            {
                exceptionSubject.Subscribe(ex => bus.PublishErrorAsync(new EventHandlingError(ex, handler))),
                Disposable.Create(() => queueClient.Close())
            };
        }
开发者ID:PhillipPruett,项目名称:Its.Cqrs,代码行数:15,代码来源:ServiceBusCommandQueueSender.cs

示例3: Main

 static void Main(string[] args)
 {
     queueClient = QueueClient.Create(queueName);
     bool keepOn = true;
     while(keepOn)
     {
         Console.Out.WriteLine("Who do you want to send a message to?");
         string name = Console.ReadLine();
         Console.Out.WriteLine("What is your message to " + name + "?");
         string message = Console.ReadLine();
         SendMessage(name, message);
         Console.Out.WriteLine("Press [ENTER] to send another message or any other key to quit");
         ConsoleKeyInfo ki = Console.ReadKey();
         keepOn = (ki.Key == ConsoleKey.Enter);
     }
     queueClient.Close();
 }
开发者ID:kennethahn,项目名称:ServiceBusRelayDemo,代码行数:17,代码来源:Producer.cs

示例4: Run

        public override void Run()
        {
            try
            {
                var nsManager = NamespaceManager.CreateFromConnectionString(CommonResources.ConnectionStrings.AzureServiceBus);
                if (!nsManager.QueueExists(QueueName))
                    nsManager.CreateQueue(QueueName);

                _client = QueueClient.CreateFromConnectionString(CommonResources.ConnectionStrings.AzureServiceBus, QueueName);
                _client.PrefetchCount = 10;

                var eventDrivenMessagingOptions = new OnMessageOptions
                {
                    AutoComplete = true,
                    MaxConcurrentCalls = 10
                };
                eventDrivenMessagingOptions.ExceptionReceived += OnExceptionReceived;

                Console.WriteLine(" > {0} - Sending {1} test messages", DateTime.Now, MsgsToSend);
                Stopwatch.Start();
                SendMessages();
                Stopwatch.Stop();
                Console.WriteLine(" > {0} - {1} of {2} sent in {3} ms", DateTime.Now, MsgsToSend, MsgsToSend, Stopwatch.ElapsedMilliseconds);

                Thread.Sleep(2000);
                Console.WriteLine(" > {0} - Recieving {1} test messages", DateTime.Now, MsgsToSend);
                Stopwatch.Restart();
                _client.OnMessage(OnMessageArrived, eventDrivenMessagingOptions);

                Console.WriteLine("Press any key to close connection");
            }
            catch (Exception ex)
            {
                Console.WriteLine(" > Exception received: {0}",
                    ex.Message);
            }
            finally
            {
                Console.ReadLine();
                _client.Close();
            }

            Console.WriteLine("Press any key to close application");
            Console.ReadLine();
        }
开发者ID:AtmosphereMessaging,项目名称:Cumulus-vNext,代码行数:45,代码来源:RawSdkImplementation.cs

示例5: Main

 static void Main(string[] args)
 {
     CreateQueue();
     queueClient = QueueClient.Create(queueName, ReceiveMode.PeekLock);
     Console.Out.WriteLine("Queue client receive mode is " + queueClient.Mode.ToString());
     try
     {
         while (true)
         {
             long msgCount = nsMgr.GetQueue(queueName).MessageCountDetails.ActiveMessageCount;
             Console.Out.WriteLine("Ready for messages... ");
             if (msgCount > 0) { Console.Out.WriteLine("The queue has " + msgCount + " messages waiting"); }
             var msg = queueClient.Receive(new TimeSpan(1, 0, 0));
             Console.Out.WriteLine("Received message with id {0}", msg.MessageId);
             Messages.Greeting greeting = msg.GetBody<Messages.Greeting>();
             Console.Out.WriteLine("Message for: {0}", greeting.Name );
             Console.Out.WriteLine("{0}\n", greeting.Message);
             if (queueClient.Mode == ReceiveMode.PeekLock)
             {
                 try
                 {
                     Console.Out.WriteLine("Completing message with lock token {0}", msg.LockToken);
                     queueClient.Complete(msg.LockToken);
                 }
                 catch (MessageLockLostException)
                 {
                     Console.Out.WriteLine("Oh noes! We lost the lock on the message. ");
                 }
             }
             Console.Out.WriteLine();
         }
     }
     finally
     {
         queueClient.Close();
     }
 }
开发者ID:kennethahn,项目名称:ServiceBusRelayDemo,代码行数:37,代码来源:Consumer.cs

示例6: CloseQueueClient

 static void CloseQueueClient(QueueClient queueClientToClose)
 {
     try
     {
         queueClientToClose.Close();
     }
     catch (Exception)
     {
         // ignored because we don't care!
     }
 }
开发者ID:geffzhang,项目名称:Rebus,代码行数:11,代码来源:AzureServiceBusTransport.cs

示例7: Main

        static void Main(string[] args)
        {
            try
            {

                //String serviceBusNamespace = "azuretest-ns";
                //String keyname = "RootManageSharedAccessKey";
                //String key = "3HzV1a5bcs/OOj0YS+Iec7XPA9ys2s9oqrUrg8pcILA=";

                //String connectionString = @"Endpoint=sb://" +
                //       serviceBusNamespace +
                //       @".servicebus.chinacloudapi.cn/;SharedAccessKeyName=" +
                //       keyname + @";SharedSecretValue=" + key;

                String connectionString = @"Endpoint=sb://azuretest-ns.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=3HzV1a5bcs/OOj0YS+Iec7XPA9ys2s9oqrUrg8pcILA=";

                int numCities = 10; // Use as the default, if no value is specified
                // at the command line.
                if (args.Count() != 0)
                {

                    if (args[0].ToLower().CompareTo("createqueue") == 0)
                    {
                        // No processing to occur other than creating the queue.
                        namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
                        namespaceManager.CreateQueue(queueName);
                        Console.WriteLine("Queue named {0} was created.", queueName);
                        Environment.Exit(0);
                    }

                    if (args[0].ToLower().CompareTo("deletequeue") == 0)
                    {
                        // No processing to occur other than deleting the queue.
                        namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
                        namespaceManager.DeleteQueue("TSPQueue");
                        Console.WriteLine("Queue named {0} was deleted.", queueName);
                        Environment.Exit(0);
                    }

                    // Neither creating or deleting a queue.
                    // Assume the value passed in is the number of cities to solve.
                    numCities = Convert.ToInt32(args[0]);
                }

                Console.WriteLine("Running for {0} cities.", numCities);

                queueClient = QueueClient.CreateFromConnectionString(connectionString, "TSPQueue");

                List<int> startCities = new List<int>();
                List<int> restCities = new List<int>();

                startCities.Add(0);
                for (int i = 1; i < numCities; i++)
                {
                    restCities.Add(i);
                }
                distances = new double[numCities, numCities];
                cityNames = new String[numCities];
                BuildDistances(@"c:\tsp\cities.txt", numCities);
                minDistance = -1;
                bestOrder = new int[numCities];
                permutation(startCities, 0, restCities);
                Console.WriteLine("Final solution found!");
                queueClient.Send(new BrokeredMessage("Complete"));

                queueClient.Close();
                Environment.Exit(0);

            }
            catch (ServerBusyException serverBusyException)
            {
                Console.WriteLine("ServerBusyException encountered");
                Console.WriteLine(serverBusyException.Message);
                Console.WriteLine(serverBusyException.StackTrace);
                Environment.Exit(-1);
            }
            catch (ServerErrorException serverErrorException)
            {
                Console.WriteLine("ServerErrorException encountered");
                Console.WriteLine(serverErrorException.Message);
                Console.WriteLine(serverErrorException.StackTrace);
                Environment.Exit(-1);
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception encountered");
                Console.WriteLine(exception.Message);
                Console.WriteLine(exception.StackTrace);
                Environment.Exit(-1);
            }
        }
开发者ID:siszoey,项目名称:getPoisFromWeibo,代码行数:91,代码来源:Program.cs


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