MarketData.MarketDataItem += new MarketDataItemEventHandler(MarketData_MarketDataIt em);
I've noticed that even when I remove the indicator from my chart, this event is still kicking off. My indicator also opens up 3 Windows forms and my question is: how can I ensure that when the indicator is removed from the chart, the above event gets unhooked and I can close out my 2 Windows forms.
I tried the following deconstructor code:
// my destructor code
~ZooPulse()
{
Print("destruct1a!");
Print("destruct3!");
zform.Close();
zform = null;
Print("destruct2!");
MarketData.MarketDataItem -= new MarketDataItemEventHandler(MarketData_MarketDataIt em);
Print("destruct4!");
//System.GC.Collect();
Print("DONE");
}
where zform is my Windows form. I get the first 2 Print statements, then nothing else. So I know it doesn't like my zform.Close(). I've tried commenting out the form cleanup and just removing the MarketData event handler, but that also doesn't print "destruct4", so I know it failed on that too.
How do I remove my event handler and close out my forms when the user Removes the indicator on the chart? Thanks.
Comment