469,946 Members | 1,584 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Form.ControlBox and Alt/F4

I have a Dialog type form that starts a worker thread,
allows the thread to update its progess and provides a
Cancel button. Following advice from Chad Meyers in a
recent posting, the worker thread updates the dialog by
calling Invoke which runs the UI update method on the UI
thread. This works nicely. (Thanks Chad)

However, if I close the dialog using the form close button
([x] top right hand corner) I get an
ObjectDisposedException when calling Invoke on the Dialog
form. So I remove the Form.ControlBox, attempting to
force the user to cancel and/or close the dialog using my
buttons. This fixes the [x] problem, but I'm still able to
close the form using Alt/F4. In this case, the Form
closes (the window disappears and the Closing event
fires), but Dispose() is not called. My worker thread
continues to run and call Invoke, apparently without

I can easily signal the worker thread to quit from the
Closing event, but I'm nervous since I don't really
understand what's going on. The documentation for
Form.ControlBox states that "If your form does not display
a control box, the form is not able to close using the
ALT+F4 keyboard combination."

My form seems to be closing but not disposing. What's
going on?

Many thanks

Nov 15 '05 #1
0 3604

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sumit | last post: by
13 posts views Thread by Sylo | last post: by
reply views Thread by Sakharam Phapale | last post: by
6 posts views Thread by Dennis | last post: by
7 posts views Thread by Miro | last post: by
3 posts views Thread by Alan T | last post: by
7 posts views Thread by =?Utf-8?B?bGpsZXZlbmQy?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.