Using .NET 2.0 / winforms. Some of our .NET classes, call some
unmanaged windows dll's. See some samples below -
<<
System.Runtime.InteropServices.DllImport("gdi32.dll"),
System.Runtime.InteropServices.DllImportAttribute("user32.dll").
Once these classes are instantiated and done being used, does the
garbage collector successfully gc them or will there be a problem in
some of these classes that use these non .NET dlls'. If so, how do we
garbage collect them.
Thanks.
Bob Powell [MVP] - 28 Mar 2008 08:38 GMT
Any managed class that uses unmanaged code should implement the dispose
pattern correctly.
See IDisposable and the various discussions on Dispose and deterministic
finalization.
You also need to respect the semantics of the API used. For example when
using GDI via interop you will still need to obey the rules of graphics
resource handle use and destruction.

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Using .NET 2.0 / winforms. Some of our .NET classes, call some
> unmanaged windows dll's. See some samples below -
[quoted text clipped - 10 lines]
>
> Thanks.