protected void Dispose(bool disposing) { if (disposing) { if (MyProcessorObject != null) { MyProcessorObject.ExitFlag = true; MyProcessorObject = null; } if (MyThread != null) { MyThread = null; } } }
/// <summary> /// Checks a processor out of the pool /// </summary> /// <returns></returns> static public RequestProcessorPoolEntry GetRequestProcessor() { RequestProcessorPoolEntry retval = null; lock (poolLock) { for (int i = 0; i < processorPool.Count; i++) { if (processorPool[i].MyCurrentState == RequestProcessorPoolEntry.EntryState.Free || ( processorPool[i].MyCurrentState == RequestProcessorPoolEntry.EntryState.Working && processorPool[i].MyProcessorObject.MyCurrentRequest == null && processorPool[i].MyThread.ThreadState == ThreadState.Unstarted) ) { retval = processorPool[i]; break; } } if (retval == null && processorPool.Count < MAX_POOL_SIZE) { retval = new RequestProcessorPoolEntry(); AsyncRequestProcessor proc = AsyncRequestProcessor.CreateProcessor(); proc.MyPoolEntry = retval; retval.MyProcessorObject = proc; retval.MyThread = new Thread(new ThreadStart(proc.ThreadStartRequestProcessing)); processorPool.Add(retval); } if (retval != null) { retval.MyCurrentState = RequestProcessorPoolEntry.EntryState.Working; } } return(retval); }