Check if object still exists
Posted on 2005-05-09
I've got a main dialog, which itself creates new dialogs. Every time I create a new dialog, I do this:
NoteForm note = new NoteForm();
That means that I save a reference to the dialog in an ArrayList called noteObjects. The dialogs can be minimized and hidden. I added a button in my main dialog that shows all dialogs. So what I do is iterating through the ArrayList and call:
If a dialog has been closed, there are invalid entries in the array which cause a System.ObjectDisposedException
How can I remove array elements that have become invalid?
if ((NoteForm)noteObjects[i] == null) ... doesn't work.
Thanks for any suggestion,