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(); } } }
public void Stop() { IsRunning = false; Listener.Stop(); try { HandleThread.Interrupt(); } catch { } HandleThread = null; Listener = null; }
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); }
public ThreadPoolHandler(HandleThread handler, System.Collections.ICollection collection, System.Threading.EventWaitHandle mre) { this.eventWaitHandle = mre; this.collection = collection; this.handler = handler; }
public ThreadPoolHandler(HandleThread handler, ICollection collection, EventWaitHandle mre) { this.eventWaitHandle = mre; this.collection = collection; this.handler = handler; }