Cook Computing

The first thing I've noticed

April 23, 2002 Written by Charles Cook

The first thing I've noticed with COM interop is that if you have managed C++ classes which are holding pointers to COM objects, the final release of the COM objects (in the destructor of the managed classes) occurs after you have called CoUninitialize (as the managed objects are finalized at program termination). Calling GC.Collect before CoUninitialize does result in the final releases happening before CoUninitialize but I just realized that the destructor of the managed classes may be called on a different thread. I remember from the course a couple of weeks ago that GC is a two phase operation - determine which objects are to finalized and then finalize them - and the second phase occurs on a background thread. So which apartment, if any, is the background thread running in? Looks like I have much to learn about COM Interop.