Re: C# COM object not being released
"techie" <techie@nospam. biz> wrote in message
news:EeednZwu35 rNrCrfRVn-gA@biscit.net.. .[color=blue]
> The main application is an MFC Windows application with a UI. The main
> MFC
> application creates a COM object. The COM object is a C# .NET COM object.
> Therefore, my COM object is a STA thread? How do I get my COM object to
> pump the message queue?
>
>[/color]
Ok, its a MFC windows application creating a .NET COM object.
1. You don't have to pump messages, like I said this is handled by the UI
thread.
2. You COM object will live in the same STA thread as the UI.
3. COM objects are released when you call Release() on their inferfaces.
4. The .NET object will be collected when the GC runs (for objects without
destructors), or when the finalizer runs (for objects that have destructors
but not implementing IDisposable). Note the the finalizer runs on a
finalizable object after the second sweep of the GC. If this object is the
sole .NET COM object in the process chances are that the GC never runs, so
the finalizer will not run either, in that case the finalizer will run when
the process shuts down.
So I suggest you apply the Disposing pattern and remove the finalizer
(destructor).
Willy.
"techie" <techie@nospam. biz> wrote in message
news:EeednZwu35 rNrCrfRVn-gA@biscit.net.. .[color=blue]
> The main application is an MFC Windows application with a UI. The main
> MFC
> application creates a COM object. The COM object is a C# .NET COM object.
> Therefore, my COM object is a STA thread? How do I get my COM object to
> pump the message queue?
>
>[/color]
Ok, its a MFC windows application creating a .NET COM object.
1. You don't have to pump messages, like I said this is handled by the UI
thread.
2. You COM object will live in the same STA thread as the UI.
3. COM objects are released when you call Release() on their inferfaces.
4. The .NET object will be collected when the GC runs (for objects without
destructors), or when the finalizer runs (for objects that have destructors
but not implementing IDisposable). Note the the finalizer runs on a
finalizable object after the second sweep of the GC. If this object is the
sole .NET COM object in the process chances are that the GC never runs, so
the finalizer will not run either, in that case the finalizer will run when
the process shuts down.
So I suggest you apply the Disposing pattern and remove the finalizer
(destructor).
Willy.
Comment