Hi
I have an object which implements IDisposable. As a result of this, anywhere it's used I'm disposing of it. However, in a few instances it is declared as a member variable in a static class.
Since static classes cannot implement interfaces I can't implement IDisposable on the static class and dispose of the object there. Also, static classes can't have finalizers so I can't dispose of the object in there. Is there a way to do safely dispose of the object in the static class Or, do I even need to worry about it since the static class will live for the lifetime of the AppDomain and disposable object will be destroyed when the static class is reclaimed anyway
Thanks!
Jeremy

Objects and implement IDisposable being used in static classes
Avi_harush
Hi Jeremy
This is really a tough thing to answer. There is no definitive and single solution for this. It entirely depends on your application design and your programming discipline. For a short time, conside the static classes as a crude way of implementing the Singletons. And singletons have the limitation of deterministic destruction. But the way they are used in our application may limit the effect of that drawback.
If we follow some discipline or guideline, it may help. Let us say that the application will always exit by a Terminate method call. In that case, the Terminate method call might need to do all uninitialization/disposal, including a call like StaticClass.Uninitialize.
Hope that helps.
Regards
Vivek Ragunathan
bitpaq.com
Thanks for the quick response, Vivek. That was what I needed to know.
Thanks again,
Jeremy