I have a static class that holds quite a few unmanaged resources (it basically loads/creates a large number of GDI+ bitmaps, brushes and pens that are likely to be used at regular intervals by the application). Being concerned about resource cleanup, I naturally ( :) ) thought about their disposal. However, static classes do not allow finalizers to be defined.
In one sense that makes sense - the reason for having a static class that manages these resources is that they are likely to be required repeatedly right up until the app shuts down. However I am a bit nervous - this means I'm entirely dependant on Windows to release all these resources when the process ends, and although Windows should do that, to be honest I'm not 100% sure I trust it to do so, I'd feel more comfortable if my managed code contained something to explicitly ensure these resources are released. (I trust .NET rather more than I trust the Windows OS :) ) Any thoughts? Am I being too cautious when I should just trust Windows to handle resource release, or is there some other way to deal with this situation? =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com