I think you should wrap those handles in an existing or new SafeHandle class
and as Shawn pointed out, when the AppDomain goes away, the SafeHandle
wrappers will be finalized and your resources released.

Sébastien
On Wed, Sep 17, 2008 at 9:25 PM, Simon Robinson <[EMAIL PROTECTED]>wrote:

> 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(R)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to