473,418 Members | 5,105 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

How is it possible to show two modal message boxes in the same thread?

OK this has me perplexed, puzzled and bamboozled!

I have a remoting service which I displayed a message box in. I then
wondered what would happen if a client made a call to the service
while the message box was being displayed. Since the call comes in on
a different thread the client call was not blocked. This seemed to
make sense to me.

Next I thought, what will happen when the client calls into the server
if I try to use a delegate to call back onto the UI thread? To my mind
I thought I should be blocked, but I was able to perform work on the
UI thread while the message box was displayed. So finally, I thought I
wonder what happens if I then also try an display another message box
on the UI thread and sure enough I was able to display two modal
message boxs on the UI thread (I put the current thread ID in the
message boxes just to make sure it was on the same thread).

I don't understand this behaviour as I think a modal dialog should
block a thread... But I am clearly wrong, I just don't know why?!

andrew
www.vbusers.com
Nov 16 '05 #1
3 2821
A MessageBox isn't really the same thing as a modal dialog. You can keep
poping up MessageBoxes until theres loads stacked up on the screen ;)

to show a modal dialog look at Form.ShowDialog and show a form.

we*******@vbusers.com (Andrew Baker) wrote in
news:c1**************************@posting.google.c om:
OK this has me perplexed, puzzled and bamboozled!

I have a remoting service which I displayed a message box in. I then
wondered what would happen if a client made a call to the service
while the message box was being displayed. Since the call comes in on
a different thread the client call was not blocked. This seemed to
make sense to me.

Next I thought, what will happen when the client calls into the server
if I try to use a delegate to call back onto the UI thread? To my mind
I thought I should be blocked, but I was able to perform work on the
UI thread while the message box was displayed. So finally, I thought I
wonder what happens if I then also try an display another message box
on the UI thread and sure enough I was able to display two modal
message boxs on the UI thread (I put the current thread ID in the
message boxes just to make sure it was on the same thread).

I don't understand this behaviour as I think a modal dialog should
block a thread... But I am clearly wrong, I just don't know why?!

andrew
www.vbusers.com


Nov 16 '05 #2
Keep in mind that neither modal dialogs or message boxes (which are
essentially a type of modal dialog) really block the current thread. The
thread is processing a message loop the whole time -- if it were blocked
with respect to the parent window, the window wouldn't be able to redraw
itself as you move the modal dialog over top of it.

The way I think of it is that each thread running a message loop has a
stack of modal dialogs. Any time a modal dialog is opened (including message
boxes), it's pushed onto the stack. All of these dialogs share the same
message pump, but that pump only allows certain messages (i.e. non-input
related) to reach windows which are not the top-most in the stack (e.g.
paint messages can get through but click events and such don't). When the
moda dialog is closed, it's popped off the stack and the next one down
becomes the "active" dialog.

So, in your experiment, you should have noticed that even though you had two
message boxes up on the same UI thread, one was "active" and the other
couldn't be closed until the active one was closed.

Ken
"Andrew Baker" <we*******@vbusers.com> wrote in message
news:c1**************************@posting.google.c om...
OK this has me perplexed, puzzled and bamboozled!

I have a remoting service which I displayed a message box in. I then
wondered what would happen if a client made a call to the service
while the message box was being displayed. Since the call comes in on
a different thread the client call was not blocked. This seemed to
make sense to me.

Next I thought, what will happen when the client calls into the server
if I try to use a delegate to call back onto the UI thread? To my mind
I thought I should be blocked, but I was able to perform work on the
UI thread while the message box was displayed. So finally, I thought I
wonder what happens if I then also try an display another message box
on the UI thread and sure enough I was able to display two modal
message boxs on the UI thread (I put the current thread ID in the
message boxes just to make sure it was on the same thread).

I don't understand this behaviour as I think a modal dialog should
block a thread... But I am clearly wrong, I just don't know why?!

andrew
www.vbusers.com

Nov 16 '05 #3
Thanks Ken,

that's an excellent explaination...

andrew
"Ken Kolda" <ke*******@elliemae-nospamplease.com> wrote in message news:<u6*************@tk2msftngp13.phx.gbl>...
Keep in mind that neither modal dialogs or message boxes (which are
essentially a type of modal dialog) really block the current thread. The
thread is processing a message loop the whole time -- if it were blocked
with respect to the parent window, the window wouldn't be able to redraw
itself as you move the modal dialog over top of it.

The way I think of it is that each thread running a message loop has a
stack of modal dialogs. Any time a modal dialog is opened (including message
boxes), it's pushed onto the stack. All of these dialogs share the same
message pump, but that pump only allows certain messages (i.e. non-input
related) to reach windows which are not the top-most in the stack (e.g.
paint messages can get through but click events and such don't). When the
moda dialog is closed, it's popped off the stack and the next one down
becomes the "active" dialog.

So, in your experiment, you should have noticed that even though you had two
message boxes up on the same UI thread, one was "active" and the other
couldn't be closed until the active one was closed.

Ken
"Andrew Baker" <we*******@vbusers.com> wrote in message
news:c1**************************@posting.google.c om...
OK this has me perplexed, puzzled and bamboozled!

I have a remoting service which I displayed a message box in. I then
wondered what would happen if a client made a call to the service
while the message box was being displayed. Since the call comes in on
a different thread the client call was not blocked. This seemed to
make sense to me.

Next I thought, what will happen when the client calls into the server
if I try to use a delegate to call back onto the UI thread? To my mind
I thought I should be blocked, but I was able to perform work on the
UI thread while the message box was displayed. So finally, I thought I
wonder what happens if I then also try an display another message box
on the UI thread and sure enough I was able to display two modal
message boxs on the UI thread (I put the current thread ID in the
message boxes just to make sure it was on the same thread).

I don't understand this behaviour as I think a modal dialog should
block a thread... But I am clearly wrong, I just don't know why?!

andrew
www.vbusers.com

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rich Wahl | last post by:
I am writing a personal application that uses windowListeners, ActionListeners and possible ItemListeners (combo boxes). I have one of the Buttons (ActionListeners) set to have a popup...
3
by: dp | last post by:
I am new to VB.NET and I have a simple question. How do I show a form from a command button click event? The code I have below is not working. I am trying to show the form frmAgent. What am I...
4
by: Drew Lettington | last post by:
I'm making a simple call to display error messages in a MessageBox from a Windows form and the MessageBox is not behaving in a modal fashion. My modal form displays, the user clicks a button and...
3
by: Earl Teigrob | last post by:
Can a Modal Dialog Box do forms ASP.NET forms validation from within the Modal Box? I want to pop up a dialog box to the user and have it do its own post backs with validation checking and then...
4
by: Brian Henry | last post by:
Hi, is there a way to get a form to post back to a modal dialog box when it was posted from a modal dialog to start with? here is the problem... I have a form with combo boxes and when you select...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
0
by: Lee | last post by:
I wonder if there's any way around this. I open a window as a modal form, but I would like to have pop up message boxes appearing on top of this that are non modal (so the user can close...
24
malav123
by: malav123 | last post by:
Hi, I am using ajax toolkit's modal popup extender which contains few text boxes and two buttons on it... i want to put validation on some of text boxes but my problem is after...
6
by: akshaycjoshi | last post by:
There are some textboxes placed on a form along with one button.When the user presses the button a modal window pops up till the work is finished and that window shows that circling processing GIF...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.