On Mon, 05 May 2008 23:04:11 -0700, shark <ma**@poczta.onet.plwrote:
So in our cases we have two windows: first is main form window and the
second in modal dialog.
Are they created in the same thread?
Impossible to answer without seeing the code. The windows are created in
whatever thread executes the code that creates them. But by default,
without you introducing an additional thread to the picture, yes...the
modal dialog would be created on the same thread as any other window.
How many message pump do we have in this case (seems like 2)?
Why do you say "seems like 2"? Assuming the modal dialog is created in
the same thread as the main form window, then there will only be a single
message pump running at a given time. When the modal dialog is being
shown, the message pump that handles the modal nature of the dialog will
be pumping messages for _all_ windows that had been created on that thread.
If you create the modal dialog on a different thread, then you'll have two
message pumps: the main GUI thread's pump, and the one that's started when
you show the modal dialog. But so far you haven't given any reason for us
to believe that the modal dialog is created on a different thread.
If you have some specific code to show, it will be possible to tell you
whether more than one thread is involved. Otherwise, it won't be possible
to say for sure. But generally speaking, if you are showing a modal
dialog in response to some event raised by an existing Control instance
(including, for example, a form), without delegating that work to some
other thread, the modal dialog will be created on the same thread in which
that existing Control instance was created.
Pete