I am created a class inherited from ApplicationContext in .NET and I'm wondering where is best to raise my OnClosing event. Now, ApplicationContext has a "ThreadExit" event, but this fires after both ExitThread and ExitThreadCore have run. Is this where a typical OnClosing event would go? This seems more like where a OnClosed event would go.
As a follow up, where should my OnClosed event go? overriding Dispose and putting it at the beginning seems plausible I suppose. Would the end of Dispose be safe? Or might the OnClosed even need something that was just deleted?
Edit: So it looks like I have to use the ThreadExit event inherited from ApplicationContext. My question now would be, is it safe to cancel the closing from here? Also still, where should I fire my OnClosed from?