Ejemplo n.º 1
0
        // Processing for sndThrd to pull msgs out of sndBlockingQ
        // and post them to another Peer's Communication service

        void ThreadProc()
        {
            while (true)
            {
                TestHarness.Message msg = sndBlockingQ.deQ();
                channel.PostMessage(msg);
                // if (msg == "quit")
                //    break;
            }
        }
Ejemplo n.º 2
0
        void ThreadProc()//This thread is for receiving results from Test Harness,
        {
            while (true)
            {
                // get result out of receive queue - will block if queue is empty
                rcvdMsg = recvr.GetMessage();

                // call window functions on UI thread
                this.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    OnNewMessage,
                    rcvdMsg);
            }
        }
Ejemplo n.º 3
0
 //----< called by UI thread when dispatched from rcvThrd >-------
 void OnNewMessageHandler(TestHarness.Message msg)
 {
     Console.Write("\nReceiving Test Result from Test Harness.");
     ConsoleBox.Text = "";                                  //If there is a result received
     if (msg.body.Contains("does Not Exist in Repository")) //if file does not exist, alert
     {
         System.Windows.Forms.MessageBox.Show(msg.body);
         Console.Write("\n  File Not Exist in Repository --------Project 4. Req 3");
         return;
     }
     foreach (string line in msg.ResultLogs)
     {
         ConsoleBox.Text = ConsoleBox.Text + line + "\n";//put the result to the Text Box
     }
     SendMsg.IsEnabled = true;
     TestTime.Stop();
     Console.WriteLine("The test time is " + TestTime.ElapsedMicroseconds + "--------Project 4. Req 12");
     Console.Write("\n  Test Harness Server send back Result to Client --------Project 4. Req 6 and 7");
 }
Ejemplo n.º 4
0
        public MainWindow() //Constructor
        {
            InitializeComponent();
            OnNewMessage += new NewMessage(OnNewMessageHandler);

            Console.Write("\n  Demonstrating Client {0} - Project #4 with Threading", Process.GetCurrentProcess().Id.ToString());
            Console.Write("\n =======================================================");

            TestRequest      = new TestHarness.Message(); // This message is prepared for the new Test Request
            TestRequest.tr   = new TestHarness.testRequest();
            TestRequest.to   = "TH";
            TestRequest.from = "CL";


            string localPort = Process.GetCurrentProcess().Id.ToString(); // the process ID is the port. And this port will be inserted into the message

            TestRequest.port = localPort;
            string endpoint = "http://localhost:" + localPort + "/IMessage";

            try
            {
                recvr = new TestHarness.ReceiverMsg();
                recvr.CreateRecvChannel(endpoint); //create the channel and start the receive thread.

                // create receive thread which calls rcvBlockingQ.deQ() (see ThreadProc above)
                rcvThrd = new Thread(new ThreadStart(this.ThreadProc));
                rcvThrd.IsBackground = true;
                rcvThrd.Start();
                connect.IsEnabled = true;
                SendMsg.IsEnabled = false;
                Browse.IsEnabled  = false;
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
        }
Ejemplo n.º 5
0
        // Implement service method to receive messages from other Peers

        public void PostMessage(TestHarness.Message msg)
        {
            rcvBlockingQ.enQ(msg);
        }