472,799 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 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 2758
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.