Form.ShowDialog is abnormal after Application.Run

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

[STAThread]
Main
{
Application.Run(new Form1());
new Form2().ShowDialog();
}

Form2 can't be show. WhatZ the throuble? it seems no messageloop
 
凯仔 said:
[STAThread]
Main
{
Application.Run(new Form1());
new Form2().ShowDialog();
}

Form2 can't be show. WhatZ the throuble? it seems no messageloop

The lines above start Form1 as the main form. There's just 1 thread
(STAThread), as most gui's just use 1 thread, so application.run,
starts the form and passes the execution to that form, which then is
the executing code on the single thread of the application. If you also
want to show form2, open it from form1.

Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
But why the following code is right ?
new Form2().ShowDialog();
Application.Run(new Form1());


Frans Bouma said:
凯仔 said:
[STAThread]
Main
{
Application.Run(new Form1());
new Form2().ShowDialog();
}

Form2 can't be show. WhatZ the throuble? it seems no messageloop

The lines above start Form1 as the main form. There's just 1 thread
(STAThread), as most gui's just use 1 thread, so application.run,
starts the form and passes the execution to that form, which then is
the executing code on the single thread of the application. If you also
want to show form2, open it from form1.

Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
 
Back
Top