public static void Abort(ThreadStyle name) { for (int i = 0; i < Threads.Count; i++) { if (Threads[i].Name == name.ToString()) { try { if (name == ThreadStyle.测试线程) { //TestTaskDispatcher.IsStop = true; } else { Threads[i].Abort(); } Threads.Remove(Threads[i]); } catch (Exception) { } } } }
public static void Start(ThreadStart start, ThreadStyle name = ThreadStyle.默认) { Thread thread = new Thread(start); thread.IsBackground = true; thread.Name = name.ToString(); thread.Start(); Threads.Add(thread); }