/// <summary> /// Proxifies the taskFor function call. /// </summary> /// <param name="i"></param> /// <param name="func"></param> private void forTaskProxy(System.Object data) { // Start the function for the thread with the given i threadData dataCasted = (threadData)data; dataCasted.taskFunction(dataCasted.i); }
/// <summary> /// Starts a new thread with the given index. /// </summary> /// <param name='i'> /// I. /// </param> /// <param name='taskImplementation'> /// Task implementation. /// </param> private void startThread(int i, taskFor taskImplementation) { int threadId = this.getFreeThread(); // No free thread case if (threadId == -1) { // Wait for a new thread to get free Thread.Sleep(10); this.startThread(i, taskImplementation); return; } // Instantiate parameterized thread start and thread ParameterizedThreadStart pts = new ParameterizedThreadStart(this.forTaskProxy); this.threads[threadId] = new Thread(pts); // Instantiate the thread data threadData data = new threadData(); data.i = i; data.taskFunction = taskImplementation; // Start the thread with the generated threadData object this.threads[threadId].Start(data); }
public static threadData GetNextThreadLine() { threadData result; if (threadList.Count <= 0) { result = new threadData(); result.processNumber = -1; // flag invalid response result.PID = -1; result.processCmdLine = ""; result.threadNumber = -1; result.daemonThread = false; result.threadState = false; result.currentThread = false; result.TID = -1; result.moreData = false; return(result); } result = (threadData)threadList[0]; threadList.RemoveAt(0); return(result); }
public static threadData GetNextThreadLine() { threadData result; if (threadList.Count <= 0) { result = new threadData(); result.processNumber = -1; // flag invalid response result.PID = -1; result.processCmdLine = ""; result.threadNumber = -1; result.daemonThread = false; result.threadState = false; result.currentThread = false; result.TID = -1; result.moreData = false; return result; } result = (threadData)threadList[0]; threadList.RemoveAt(0); return result; }