I have ActiveX ( COM ) control implented in C# that used in Internet Explorer. My control uses unmanaged resourses and I need know when tab(window) with control will be closed to release resources.
How my control can know that IE tab (window) with ActiveX( COM ) control was closed (without javascript call control methods when window closed)?
Asked
Active
Viewed 740 times
0

Alex Sebastiano
- 67
- 6
-
possible duplicate What is the proper way for an activeX (COM) control to clean up when closed by its parent? http://stackoverflow.com/questions/3390571/what-is-the-proper-way-for-an-activex-com-control-to-clean-up-when-closed-by-it – Sheng Jiang 蒋晟 Jun 26 '11 at 18:36
2 Answers
0
An ActiveX control is based on COM, which uses refcounting. Your control should dispose its resources when it's refcount goes to zero. This is not trivial to detect from a C# activex control, but according to this question's answer, it is doable.

Community
- 1
- 1
0
If you are writing a UserControl
override OnHandleDestroyed
and place your resource releasing code there.
Don't forget to call base.OnHandleDestroyed
after your code in that method.

alisabzevari
- 8,008
- 6
- 43
- 67