//listen thread ussed to listen for messages static void listen() { TestHarness loader = new TestHarness(); while (true) { ClientEnvironment.verbose = true; CommMessage crcvMsg = comm.getMessage(); if (crcvMsg.body != null && crcvMsg.command != null) { if (ClientEnvironment.verbose) { crcvMsg.show(); } if (crcvMsg.command.Equals("testrequest")) { Console.WriteLine("\n Received Test Request Message from child process {0} and enqueued in the test request queue", crcvMsg.port); Console.WriteLine("\n ----------------------------------------------------------"); TrQ.enQ(crcvMsg.port + " " + crcvMsg.body); } else if (crcvMsg.body != null && crcvMsg.body.Equals("DllTransferCompleted")) { isDllReceived = true; } else if (crcvMsg.port == 8095 && crcvMsg.body != null && crcvMsg.body.Equals("logsreceived")) { deletefiles(); isHarnessAvailable = true; } } Thread.Sleep(1000); } }
//dequeueing process queue and start testing first test request static void allocateprocess() { Console.WriteLine("\n Test harness waiting for test requests"); Console.WriteLine("\n ================================================="); while (true) { if (TrQ.size() > 0) { if (isHarnessAvailable) { string request = TrQ.deQ(); int index = request.IndexOf(' '); if (index != -1) { string portno = request.Substring(0, index); string files = request.Substring(index + 1); CommMessage sndMsg = new CommMessage(CommMessage.MessageType.request); sndMsg.command = "dllrequest"; sndMsg.author = "Dinesh Dhamotharan"; sndMsg.to = "http://localhost:" + portno + "/IPluggableComm"; sndMsg.from = "http://localhost:8077/IMessagePassingComm"; sndMsg.body = files; sndMsg.port = 8077; Console.WriteLine("\n reached here"); comm.postMessage(sndMsg); Console.WriteLine("\n sending message:" + files + "to child:" + portno); } } } } }