473,698 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

does ShowDialog start new thread ?

Hi,

Does Form.ShowDialog () start new thread ?
If yes how is solved cross-thread operations?

Thx
Jun 27 '08 #1
14 6793
shark wrote:
Hi,

Does Form.ShowDialog () start new thread ?
If yes how is solved cross-thread operations?

Thx
No, it doesn't.

--
Lasse Vågsæther Karlsen
mailto:la***@vk arlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #2
On May 5, 4:26*pm, Lasse Vågsæther Karlsen <la...@vkarlsen .nowrote:
shark wrote:
Hi,
Does Form.ShowDialog () start new thread ?
If yes how is solved cross-thread operations?
Thx

No, it doesn't.

--
Lasse Vågsæther Karlsen
mailto:la...@vk arlsen.nohttp://presentationmod e.blogspot.com/
PGP KeyID: 0xBCDEA2E3
I was under a notion that Show and ShowDialog would executeon a
different thread. Seems interesting..Th anks Lasse.
Jun 27 '08 #3
On 5月5日, 下午7时29分 , "Aneesh Pulukkul [http://dotnet-
revolutions.blo gspot.com]" <anees...@gmail .comwrote:
On May 5, 4:26 pm, Lasse Vågsæther Karlsen <la...@vkarlsen .nowrote:
shark wrote:
Hi,
Does Form.ShowDialog () start new thread ?
If yes how is solved cross-thread operations?
Thx
No, it doesn't.
--
Lasse Vågsæther Karlsen
mailto:la...@vk arlsen.nohttp://presentationmod e.blogspot.com/
PGP KeyID: 0xBCDEA2E3

I was under a notion that Show and ShowDialog would executeon a
different thread. Seems interesting..Th anks Lasse.
Every window should have a thread to process messages, right?
Jun 27 '08 #4
"Aneesh Pulukkul [http://dotnet-revolutions.blo gspot.com]"
<an******@gmail .comwrote:
I was under a notion that Show and ShowDialog would executeon a
different thread.
Try putting code after ShowDialog. It won't run until that second window
closes. If ShowDialog just launched another thread, the code after
ShowDialog would run immediately.

Eq.
Jun 27 '08 #5
Hmm, I think that this is not a proof, because each modal window have it's
own message queue and that's why code after ShowDialog will not execute.
"Paul E Collins" <fi************ ******@CL4.orgw rote in message
news:fp******** *************** *******@bt.com. ..
"Aneesh Pulukkul [http://dotnet-revolutions.blo gspot.com]"
<an******@gmail .comwrote:
>I was under a notion that Show and ShowDialog would executeon a different
thread.

Try putting code after ShowDialog. It won't run until that second window
closes. If ShowDialog just launched another thread, the code after
ShowDialog would run immediately.

Eq.

Jun 27 '08 #6
shark wrote:
Hi,

Does Form.ShowDialog () start new thread ?
If yes how is solved cross-thread operations?
This may not be a perfect test, but I just ran a simple form with a CancelButton
setup using ShowDialog(), and had the threads window open in VS2005 (Debug ->
Windows -Threads) and no new threads appeared to spawn to handle the dialog.

There may be other reasons why that happened though.

Chris.
Jun 27 '08 #7
On Mon, 05 May 2008 05:19:41 -0700, Robin <zo********@gma il.comwrote:
Every window should have a thread to process messages, right?
Wrong. A thread that owns one or more windows will have a single message
pump loop that dispatches messages to _all_ windows owned by that thread.
Jun 27 '08 #8
On Mon, 05 May 2008 07:27:21 -0700, shark <ma**@poczta.on et.plwrote:
Hmm, I think that this is not a proof, because each modal window have
it's own message queue and that's why code after ShowDialog will not
execute.
Why do you think each modal window has its own message queue?

There's a single queue per thread, messages for all windows owned by that
thread are placed in the queue, and a given thread will have a single
message pump loop active at any given time. Your premise is false, so no
conclusion based on premise that could be useful.

As for why code after ShowDialog() doesn't execute until the window is
closed...

In the case of a modal window, the modal code that handles displaying the
window runs its own message pump loop and doesn't return until the window
is closed. That's why the code after ShowDialog() won't execute until the
window is closed.

But the message pump loop handling the modal window is running on the same
thread in which you called ShowDialog(), and will dispatch messages to
_all_ windows owned by that thread, not just the modal window that was
displayed.

Pete
Jun 27 '08 #9
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?
How many message pump do we have in this case (seems like 2)?


"Peter Duniho" <Np*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Mon, 05 May 2008 05:19:41 -0700, Robin <zo********@gma il.comwrote:
>Every window should have a thread to process messages, right?

Wrong. A thread that owns one or more windows will have a single message
pump loop that dispatches messages to _all_ windows owned by that thread.
Jun 27 '08 #10

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

Similar topics

3
5982
by: Isaac Rajan | last post by:
Hello, I have installed MSDE2000A on a standalone PC with Win ME O/s. The PC was earlier used on a Lan and has a Lan card. I could install a named instance of the server successfully but the server does not start when I attempt to start it using the service manager. Could you tell me how this could be solved? Thanks in advance.
2
1371
by: Dayne | last post by:
Does an asychronous thread (.beginInvoke) die when the method call ends? DT
75
9867
by: Beni | last post by:
I have been programming in C for about a year now. It sounds silly, but I never took the time to question why a C(or C++ or Java) program execution begins only at the main(). Is it a convention or is there some deeper underlying reason?
1
4348
by: Suman | last post by:
We are facing a problem with a Service we developed. It does not start after a re-boot. We can Start/Stop the service from the interfacing Application and the Services Control Panel all day long. But it does not start after a reboot. Details We have implemented the Service using CAtlServiceModuleT (ATL 7.0). For initialization and un-initialization, we have overridden the PreMessageLoop and the PostMessageLoop. In the initialization...
1
35048
by: aberry | last post by:
I have text file which contain Unicode data (say inp.txt) I read file using following code:- import codecs infile = codecs.open('C:\\tdata\\inp.txt','r','utf-16',errors='ignore') data = infile.readlines() If I run above code ... it throws following error :-
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.