T
Ted Miller
Isn't this what GC.WaitForPendingFinalizers is for?
For example I use an external COM object over which I have no control, that
keeps a file open for exclusive access. When the COM object is destroyed,
the file is released. Fine in COM but the rest of my C# program wants to
open that file for read access once I've finished using the COM object to
manipulate the file.
The following:
MyComObject obj = new MyComObject("filename");
//...
obj = null;
GC.Collect();
does not work reliably, but the addition of
GC.WaitForPendingFinalizers()
seems to do the trick.
--
For example I use an external COM object over which I have no control, that
keeps a file open for exclusive access. When the COM object is destroyed,
the file is released. Fine in COM but the rest of my C# program wants to
open that file for read access once I've finished using the COM object to
manipulate the file.
The following:
MyComObject obj = new MyComObject("filename");
//...
obj = null;
GC.Collect();
does not work reliably, but the addition of
GC.WaitForPendingFinalizers()
seems to do the trick.
--