« The scope bug of "for loop" | 回到主頁面 | Gmail new features!! »

March 31, 2005

Finalizer, Dispose, Close


將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati

Designing .NET Class Libraries: Designing for a Managed Memory WorldDesigning .NET Class Libraries is very good place that I am used to go here and study something anout .NET Framework. I also like Brad Abrams very much, because hi usually use very simple example to explain such hard thing like "dispose", "finalizer", "Manage code", "CLR" ... . In the speechDesigning for a Managed Memory WorldBrad Abrams focus on "Gabage Colloection", and talking about finalizer (seems he like this word more than destructor) , dispose( I think dispose is new concept in .NET framework, but it really hard to use it well).

He also talk about try {} ,excption{} and finally {} to manage the memory well. Nested use try{} finally {} can make exception more clear and can handle more condition even we don't think it will happen.

static void CopyFile(file sourcdeFile, file destFile){

try {

    OpensourceFile(sourcdeFile);

   try { OpensourceFile(destFile);  }

   finally { CloseFile(destFile); }

   }

 finally { CloseFile(sourcdeFile); }

}

Important concept about GC (Gabage Collection) is when dispose, close, finalize call? The anwser is use code to call dispose and close; but GC will call finalize when this object should be collection back.



VC6相關問題

由 Evan 發表於 March 31, 2005 將此網頁加入【百度收藏】... 加入此網頁到【del.icio.us 書籤】 technorati
引用
本文的引用網址:


以下是前來引用的連結 'Finalizer, Dispose, Close' 來自 Blog E
迴響
發表迴響









記住我的資訊?




(請輸入以下的驗證碼)