/// <summary> /// Excecutes threads on queue until none are left /// </summary> /// <param name="join">Wait for ThreadInstance to finish before re-joining with the main thread?</param> private void RunThreads(bool join = false) { if (ThreadQueue.Count() <= 0) { return; } ThreadInstance = new Thread(() => { ThreadingEventArgs args = new ThreadingEventArgs(); args.ThreadQueue = ThreadQueue; OnThreadQueueStarted(args); while (ThreadQueue.Count > 0) { RunThread(); } OnThreadQueueFinished(null); }); ThreadInstance.IsBackground = true; ThreadInstance.Start(); if (join) { ThreadInstance.Join(); } }