When you only display a Form using ShowDialog (not Show) it shouldn't be
getting closed unless you are explicitly destroying it. What are you trying
to accomplish overall? It seems like you may be trying to access that Form,
or something on that Form, after it has been marked for disposal. The code
pattern that I usually follow when showing a dialog as modal is as follows.
Of course, this creates the dialog, and marks it for disposal when done,
everytime you need it.
What I want is to put up a modal dialog which the user may cancel.
However an external hardware operation (putting in a USB Drive in this
case) can also remove it from visibility.
So the dialog may say, 'Please put in the USB Drive or click cancel to
abort'.
Then they can click cancel or wait for ever or put in the USB drive (which
generates a WM_DEVICECHANGE message) and the system can then proceeed to
remove the dialog and carry on with its normal work.
I'm sure I've done it a dozen times in C++ and VB, just learning the new
paradigm, I guess.
An equivalent sort of functionality would be a dialog which disappears
after waiting 3 minutes for an input.
Hope this makes it clearer.
Iain