强行终止你就加 try{} catch{} 只能这样

解决方案 »

  1.   

    Thread的Abort方法会触发一个异常(具体什么没看过)
    我每次都调用Abort方法 终止线程
    如果你不想看到异常 而又必须强行终止的话 试试这个类
    public class MyThread :IDisposable
            {
                Thread ths = null;            public bool IsWork { get; set; }            public MyThread()
                {
                    IsWork = true;
                    ths = new Thread((obj) =>
                    {
                        while (IsWork)
                        {
                            Console.WriteLine(Guid.NewGuid().ToString());
                            Thread.Sleep(1000);
                        }
                    });
                    ths.IsBackground = true;
                    ths.Start();
                }            public void Dispose()
                {
                    
                }
            }
            class Program
            {
                static void Main(string[] args)
                {
                    MyThread ths = new MyThread();
                    Thread.Sleep(10000);
                    ths.IsWork = false;
                    Console.ReadLine();
                }
            }
    额 你问的是这个吗