Esempio n. 1
0
 private void sendAllMessages_Click(object sender, RoutedEventArgs e)
 {
     if (!_isSendingUAGMessages)
     {
         _isSendingUAGMessages = true;
         allUAGButton.Content  = "Stop Sending All UAG Messages";
         OriginalBdtCasMessage bdtCasObject = new OriginalBdtCasMessage();
         OriginalNavMessage    navObject    = new OriginalNavMessage();
         Thread allUAGSenderThread          = new Thread(delegate()
         {
             while (_isSendingUAGMessages)
             {
                 _bdtCasRabbitMQ.SendMessage(bdtCasObject);
                 _navRabbitMQ.SendMessage(navObject);
                 Thread.Sleep(1000);
                 Console.WriteLine("Send Nav And BdtCas Message");
             }
         });
         allUAGSenderThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception
         allUAGSenderThread.Start();
     }
     else
     {
         _isSendingUAGMessages = false;
         allUAGButton.Content  = "Start Sending All UAG Messages";
         Console.WriteLine("Stop Send Messages");
     }
 }
Esempio n. 2
0
        private void sendNavMessages_Click(object sender, RoutedEventArgs e)
        {
            OriginalNavMessage navObject       = new OriginalNavMessage();
            Thread             navSenderThread = new Thread(delegate()
            {
                while (true)
                {
                    _navRabbitMQ.SendMessage(navObject);
                    Thread.Sleep(1000);
                }
            });

            navSenderThread.SetApartmentState(ApartmentState.STA); // needs to be STA or throws exception
            navSenderThread.Start();
        }