public void SetThreads() { if (!e_abort.WaitOne(0, false)) { int difference = (int)Properties.Settings.Default.ThreadCount - threads.Count; lock (threads) { while (difference < 0) { TaskThread victim = threads[0]; victim.End(); ++difference; } while (difference > 0) { TaskThread t = new TaskThread(this); t.Start(); --difference; } } } else { lock (threads) { foreach (TaskThread tt in threads) { tt.End(); } } } }
internal void UnRegisterThread(TaskThread taskThread) { int newcount = 0; lock (threads) { threads.Remove(taskThread); newcount = threads.Count; if (!ThreadsActive() && e_abort.WaitOne(0, false)) { mainForm.BeginInvoke(mainForm.threadended); } } }
internal void RegisterThread(TaskThread taskThread) { int newcount = 0; lock (threads) { threads.Add(taskThread); newcount = threads.Count; } lock (ThreadCountChanged) { if (ThreadCountChanged != null) { // ThreadCountChanged.(this, new ThreadEventArgs(newcount)); } } }