這難道不是安全地調用: component.Dispose(); (如果我檢查空)從終結 ,如果我改變的代碼如下: ~MyResource()
{
Dispose();
}
public void Dispose()
{
// Check to see if Dispose has already been called.
if(!this.disposed)
後終結不叫我的測試代碼: public class A : CriticalFinalizerObject
{
~A()
{
File.WriteAllText("c:\\1.txt", "1z1z1");
}
}
class Program
{
static void Main(string[] args)
{