tags:

views:

42

answers:

1

Hi,

I have a small win form app that consists of a form and a systray icon.

When the user closes the app from the systray I get the ObjectDisposedException as some controls (task icon) still try and access the main windows form.

I have tried wrapping the code that access the systray in a if(!this.IsDisposed) wrapper, however the check for this is always bypassed.

Am I missing something that I should be doing here? This seems quite trivial.

Thanks.

A: 

You're in control of what happens when the user closes the app. Close things in the right order (based on what forms/controls reference other forms/controls) and you can avoid this problem without hacking in IsDisposed checks.

Sam
Thanks for the suggestion, I took another look at my code and found I was able to solve this defensively and clean-up all my controls appropriately before I got to that state.
GT