OdeToCode IC Logo

Even More On Static Members

Thursday, December 23, 2004

Bruce brought up an important point about my MSDN article that I left understated. In order to show the full impact of the beforefieldinit flag on a type constructor, the code has to compile with optimizations.

Also, many optimizations take place with the JIT compiler, but the JIT doesn’t optimize when the app is running under the debugger. See John Lam’s post “Beware of Heisenberg effects” for in-depth coverage.

Static methods are debated regularly in the forms and newsgroups. I posted two little OdeToCode tidbits on the subject: Statics & Thread Safety Part I and Part II.

nick Caniglia Friday, January 7, 2005
I had question that I was hoping your recent MSDN article "Get a Charge From Statics with Seven Essential Programming Tips" would cover.
<br>Maybe this is a stupid question, but what about disposal of static members of a class when a static member holds unmanaged resources? Can you specify a static finalizer (or something like it) for the class so that when the application unloads, the GC will call it and release the unmanaged resource?
Scott Allen Friday, January 7, 2005
<br>My initial suspicion is that you'd have to hook the DomainUnload event of the AppDomain, but let me research that for a couple days. I'll put on a new post for that one.
Comments are closed.