Пример #1
0
        public bool startlocal()   //each Test request will have its own child appdomain
        {                          //the local start part
            bool finished = false; //here finished may be need to lock

            while (q.size() != 0)
            {
                Thread th = new Thread(new ThreadStart(createChildAppDomain));
                finished = false;
                th.Start();
                Console.WriteLine("--------------this is for requirement 4-----------------\nthread start,id={0}", th.ManagedThreadId.ToString());
                th.Join();
                finished = true;
                Console.WriteLine("--------------this is for requirement 4-----------------\nthread terminate");
                q.deQ();
                //return finished;
            }
            return(finished);
        }
Пример #2
0
        /*----< closes Sender's proxy >--------------------------------*/

        public void close()
        {
            while (sndQ.size() > 0)
            {
                CommMessage msg = sndQ.deQ();
                channel.postMessage(msg);
            }

            try
            {
                if (factory != null)
                {
                    factory.Close();
                }
            }
            catch (Exception ex)
            {
                Console.Write("\n  already closed", ex);
            }
        }
Пример #3
0
        //Costructor
        MotherBuilder(int count)
        {
            connectWithRepo();
            for (int i = 1; i <= count; ++i)
            {
                int portNum = portNumber + i;
                connectWithChild(portNum);
            }
            if (ready == null)
            {
                ready = new SWTools.BlockingQueue <string>();
            }
            if (testQueue == null)
            {
                testQueue = new SWTools.BlockingQueue <string>();
            }

            Thread t = new Thread(() =>
            {
                while (true)
                {
                    if (ready.size() != 0 && testQueue.size() != 0)
                    {
                        string port          = ready.deQ();
                        CommMessage csndMsg2 = new CommMessage(CommMessage.MessageType.testRequest);
                        csndMsg2.command     = "show";
                        csndMsg2.author      = "Jim Fawcett";
                        csndMsg2.to          = "http://localhost:" + port + "/IPluggableComm";
                        csndMsg2.from        = fromAddr;
                        csndMsg2.body        = testQueue.deQ();
                        c.postMessage(csndMsg2);
                    }
                }
            });

            t.Start();
            recieveMessages(count);
        }
Пример #4
0
        private void dequeRequest( )
        {
            while (open)
            {
                if (requestedQ.size() > 0 && readQ.size() > 0)
                {
                    try
                    {
                        RequestInfo request           = requestedQ.deQ( );
                        int         childBuilderIndex = readQ.deQ( );
                        allProcessinPool[childBuilderIndex].isReady = false;



                        Console.Write("\n Deque a ready Child Builder({0}) for your request \n ", childBuilderIndex);

                        CommMessage childMsg = new CommMessage(CommMessage.MessageType.request);
                        childMsg.to   = allProcessinPool[childBuilderIndex].adress;
                        childMsg.from = "http://localhost:8080/IMessagePassingComm";
                        //childMsg.argument = request.requestStr;
                        childMsg.argument = request.msg.argument;
                        //childMsg.command = "BuildRequest";
                        childMsg.command = request.msg.command;


                        comm.postMessage(childMsg);

                        //Thread.Sleep ( 100 );
                        //readQ.enQ ( childBuilderIndex );
                        //allProcessinPool[ childBuilderIndex ].isReady = true;
                    }
                    catch
                    {
                    }
                }
            }
        }