Abort()好象能释放掉线程资源,于是乎我习惯在每个线程后面加上Thread.CurrentThread.Abort();我的本意是线程完了后就把它占用的资源释放.但是多线程时问题出来了.
Application.Run(new Form1());//老是报错Object reference not set to an instance of an object.
1.是不是Abort()把Form1提前Dispose()了?
2.不用Abort()每个线程完了后会不会自动回收资源.
C#2.0
Application.Run(new Form1());//老是报错Object reference not set to an instance of an object.
1.是不是Abort()把Form1提前Dispose()了?
2.不用Abort()每个线程完了后会不会自动回收资源.
C#2.0
Abort后并不释放资源,而是等待垃圾回收
如果线程在Abort之后没有调用过Dispose,那么需要10个垃圾回收周期才会被回收。释放资源请实现并调用IDispose接口的Dispose方法