예제 #1
0
        public System.Collections.Generic.List <Result> GetResults(HandleThread handler)
        {
            if (handler == null)
            {
                throw new System.Exception("The instance of HandleThread is null.");
            }
            if (this.beans == null || this.beans.Count < 1)
            {
                return(this.result);
            }
            if (this.beans.Count > 64)
            {
                throw new System.Exception("The count of " + typeof(Bean) + " is more than 64.");
            }
            System.Threading.ThreadPool.SetMaxThreads(ThreadUtil.WorkThreadNum, ThreadUtil.CompletionPortNum);
            System.Threading.EventWaitHandle[] eventWaitHandle = ThreadUtil.GetEventWaitHandle(this.beans.Count);
            int num = 0;

            foreach (Bean current in this.beans)
            {
                eventWaitHandle[num] = new System.Threading.ManualResetEvent(false);
                ThreadPoolHandlerTemplate @object = new SystemSmallThreadPool <Bean, Result> .ThreadPoolHandler(handler, this.result, eventWaitHandle[num]);

                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(@object.handle), current);
                num++;
            }
            System.Threading.WaitHandle.WaitAll(eventWaitHandle);
            return(this.result);
        }
        //the listener thread
        void listen()
        {
            while (true)
            {
                System.Threading.Thread.Sleep(1);

                if (socket.Pending())
                {
                    TcpClient aClient      = socket.AcceptTcpClient();
                    Thread    HandleThread = null;

                    //create a new handler
                    if (isProxy)
                    {
                        //we are just acting as a man in the middle for viewing data as it flows.
                        proxyHandler ch = new proxyHandler(aClient);
                        HandleThread = new Thread(ch.start);
                    }
                    else
                    {
                        //we are pretending to be the archrongames host server.
                        serverHandler ch = new serverHandler(aClient);
                        HandleThread = new Thread(ch.start);
                    }

                    //start the client handle
                    HandleThread.Start();
                }
            }
        }
예제 #3
0
파일: HttpServer.cs 프로젝트: kodlar/r-i-m
        public void Stop()
        {
            IsRunning = false;

            Listener.Stop();
            try
            {
                HandleThread.Interrupt();
            }
            catch { }

            HandleThread = null;
            Listener     = null;
        }
예제 #4
0
 public System.Collections.Generic.List <Result> GetResults(HandleThread handler)
 {
     if (this.beans == null || this.beans.Count < 1)
     {
         return(this.result);
     }
     this.decrementIndex = this.beans.Count;
     this.handler        = handler;
     this.doneEvent      = new System.Threading.ManualResetEvent(false);
     foreach (Bean current in this.beans)
     {
         System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.DoWork), current);
     }
     this.doneEvent.WaitOne();
     return(this.result);
 }
예제 #5
0
 public ThreadPoolHandler(HandleThread handler, System.Collections.ICollection collection, System.Threading.EventWaitHandle mre)
 {
     this.eventWaitHandle = mre;
     this.collection      = collection;
     this.handler         = handler;
 }
예제 #6
0
 public ThreadPoolHandler(HandleThread handler, ICollection collection, EventWaitHandle mre)
 {
     this.eventWaitHandle = mre;
     this.collection      = collection;
     this.handler         = handler;
 }