Hi,

A probably trivial question but i can't figure out the answer myself.

When you call ShowDialog() on a Form to display it modaly, the code located
after the ShowDialog call is not executed until the Form is closed. So it
looks like the thread in which the form runs is frozen or asleep. Of
course, it is not as the form still processes events and you can call
mehtods from this Form, etc. So what really happens when you call
ShowDialog? How come the code after it is not immediately executed? If the
ShowDialog method was just waiting for the form to be closed, the UI thread
would be frozen which is not the case. I'm sure i'm missing something
simple but what?

Thanks.

Re: ShowDialog and Thread by Christopher

Christopher
Sun Dec 05 10:36:38 CST 2004

Each program has one UI thread, this thread is responsible for processing
messages for all UI objects.
When you use the ShowDialog(), the dialog is shown in a modal state, you
have told the system that
no other window in your application can receive events. If you want a
modeless dialog, use the Show()
method instead, then both dialogs can receive messages at the same time

The same happens when you use the MessageBox class, this displays a modal
dialog. All other
processing stops until the button is pressed.

Chris

"Elp" <rockfamily@REMOVEME.hotmail.com> wrote in message
news:zw1whyumgzqa$.1hn1te4sy0out.dlg@40tude.net...
> Hi,
>
> A probably trivial question but i can't figure out the answer myself.
>
> When you call ShowDialog() on a Form to display it modaly, the code
> located
> after the ShowDialog call is not executed until the Form is closed. So it
> looks like the thread in which the form runs is frozen or asleep. Of
> course, it is not as the form still processes events and you can call
> mehtods from this Form, etc. So what really happens when you call
> ShowDialog? How come the code after it is not immediately executed? If the
> ShowDialog method was just waiting for the form to be closed, the UI
> thread
> would be frozen which is not the case. I'm sure i'm missing something
> simple but what?
>
> Thanks.