/// <summary> /// post an object to the thread pool, and start execution thread pool /// </summary> /// <param name="runObject">Pointer to an instance of class which implements IRunObject interface.</param> /// <param name="priority">Low or high. Based on this the object will be added to the front or back of the list.</param> public void Run(IRunObject runObject, ThreadPriority priority = ThreadPriority.Low) { FunctionData functions = new FunctionData(); functions.RunObject = runObject; functions.ThreadFunc = null; functions.param = null; lock (this) { if (priority == ThreadPriority.Low) { m_functionList.AddLast(functions); } else { m_functionList.AddFirst(functions); } foreach (ThreadData pThreadData in m_threads) { if (pThreadData.bFree == true) { pThreadData.bFree = false; pThreadData.WaitHandle.Set(); break; } } } }