Hello, Jason
When you set the COM interface object to null you make the interface object eligible for garbage collection, but the object doesn't get garbage collected right then and there!!! The .Net Garbage Collector tries to minimize overhead by running in the background which means you can never be sure when any particular object will be finalized!! So, you should release your Burning object manually by calling the System.Runtime.InteropServices.Marshal.ReleaseComObject(your_burning_object) method;
private void OnStopBurningProgress() { ...
// Now, we should release the current DataBurner object System.Runtime.InteropServices.Marshal.ReleaseComObject(m_udfDataBurner); // Create new DataBurner object m_udfDataBurner = new UDFDataBurnerClass();
... }
You should be very careful when using this approach ( ReleaseComObject ). Since this basically force the COM reference count to zero, this can have the effect of deactivating the COM server even when the server should not be deactivated - for example when other references to the COM object still exist. So, you should set the all DataBurner, DataFolder and DataFile members(variables) to null before calling the ReleaseComObject method.
Regards,
Dmitry
|