I have a CDialog derived MFC dialog box that contains a winforms user control by utilizing /clr support and CWinFormsControl:
CWinFormsControl<MyNamespace::MyUserControl> m_userControl;
Everything is working great except for one thing. I have a timer on the control:
private System.Windows.Forms.Timer flashTimer;
this.flashTimer.Enabled = true;
this.flashTimer.Interval = 1000;
this.flashTimer.Tick += new System.EventHandler(this.FlashTimerTick);
There are also a couple of simple properties and another timer that updates a value from a web service. Nothing very complicated at all.
The problem is, after the dialog is dismissed, the timer's Tick event keeps firing, and my control continues to run on and on forever and ever. I would assume that once the HWND was destroyed, the timer would stop and the GC would eventually clean up my object.
I've had a lot of experience with C#/WinForms and C++/MFC, but this is pretty much the first time I've tried to use them together like this. Am I missing something? Do I need to do some sort of manual clean up of the user control?