Summary


This chapter introduced the CLR. It discussed the memory management features of the CLR, including how the CLR eliminates the circular reference problem that has plagued COM developers. Next, the chapter examined the Finalize method and explained why it should not be treated like the Class_Terminate method. Chapter highlights include the following:

  • Whenever possible, do not implement the Finalize method in a class.

  • If the Finalize method is implemented, then also implement the IDisposable interface that can be called by the client when the object is no longer needed.

  • Code for the Finalize method should be as short and quick as possible.

  • There is no way to accurately predict when the GC will collect an object that is no longer referenced by the application (unless the GC is invoked explicitly).

  • The order in which the GC collects objects on the managed heap is nondeterministic. This means that the Finalize method cannot call methods on other objects referenced by the object being collected.

  • Leverage the Using keyword to automatically trigger the execution of the IDisposable interface.

This chapter also examined the value of a common runtime and type system that can be targeted by multiple languages. You saw how the CLR offers better support for metadata. Metadata is used to make types self-describing and is used for language elements such as attributes. Included were examples of how metadata is used by the CLR and the .NET class library, and the chapter showed you how to extend metadata by creating your own attributes. Finally, the chapter presented a brief overview of the Reflection API and the IL Disassembler utility (ildasm.exe), which can display the IL contained within a module.




Professional VB 2005 with. NET 3. 0
Professional VB 2005 with .NET 3.0 (Programmer to Programmer)
ISBN: 0470124709
EAN: 2147483647
Year: 2004
Pages: 267

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net