Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
GeneralRe: Creating Multiple Forms in my application Pin
Christian Graus8-Nov-05 15:16
protectorChristian Graus8-Nov-05 15:16 
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier8-Nov-05 16:55
kourvoisier8-Nov-05 16:55 
GeneralRe: Creating Multiple Forms in my application Pin
Christian Graus8-Nov-05 17:13
protectorChristian Graus8-Nov-05 17:13 
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier8-Nov-05 17:21
kourvoisier8-Nov-05 17:21 
GeneralRe: Creating Multiple Forms in my application Pin
Christian Graus8-Nov-05 17:35
protectorChristian Graus8-Nov-05 17:35 
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier8-Nov-05 19:18
kourvoisier8-Nov-05 19:18 
GeneralRe: Creating Multiple Forms in my application Pin
Christian Graus9-Nov-05 10:18
protectorChristian Graus9-Nov-05 10:18 
GeneralRe: Creating Multiple Forms in my application Pin
S. Senthil Kumar8-Nov-05 20:01
S. Senthil Kumar8-Nov-05 20:01 
kourvoisier wrote:
static void Main()
{
class1 myClass = new class1();
myClass.myForms[0].Show();

}


That is what is creating the problem. For a Windows application to run properly, it needs a message pump to process messages from the operating system. For the .NET API, Application.Run[^] does the message looping. In your program, you don't have a message loop and that is what is causing the problem. This code will help you get rid of the problem.
class1 myClass = new class1();
myClass.myForms[0].Show();
Application.Run();


However, it now becomes your responsibility to handle termination of the application. Application.Run will continue processing messages even if you've closed all the forms. Ideally, you'd have one main form, and from within that, launch other forms
static void Main()
{
   Application.Run(new MyMainForm());
}

class MyMainForm()
{
   private void MyMainForm_Load()
   {
      myClass.myForms[0].Show();
   }
}


This way, when MyMainForm is closed, the application shuts down cleanly.

Either way, remember that all the forms share the same message loop, so if one of them is busy processing something, all the other forms will also appear to be hung.

To learn more about message pumps, you might want to read this[^] article.

Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier9-Nov-05 12:16
kourvoisier9-Nov-05 12:16 
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier9-Nov-05 17:36
kourvoisier9-Nov-05 17:36 
QuestionIs there any... Pin
KORCARI8-Nov-05 11:31
KORCARI8-Nov-05 11:31 
QuestionStart up with windows Pin
shdelpiero8-Nov-05 10:20
shdelpiero8-Nov-05 10:20 
AnswerRe: Start up with windows Pin
Jon Rista8-Nov-05 10:29
Jon Rista8-Nov-05 10:29 
QuestionHelp ,Please. Pin
shdelpiero8-Nov-05 10:13
shdelpiero8-Nov-05 10:13 
AnswerRe: Help ,Please. Pin
MoustafaS8-Nov-05 13:28
MoustafaS8-Nov-05 13:28 
QuestionDetecting Controls Under Mouse Cursor With Click and Drag Pin
redfish348-Nov-05 8:59
redfish348-Nov-05 8:59 
AnswerRe: Detecting Controls Under Mouse Cursor With Click and Drag Pin
Jon Rista8-Nov-05 10:25
Jon Rista8-Nov-05 10:25 
GeneralRe: Detecting Controls Under Mouse Cursor With Click and Drag Pin
redfish3410-Nov-05 11:10
redfish3410-Nov-05 11:10 
QuestionPassing data from WORD to a Web Page Pin
DenMelton8-Nov-05 8:34
DenMelton8-Nov-05 8:34 
AnswerRe: Passing data from WORD to a Web Page Pin
K edar V18-Oct-06 20:11
K edar V18-Oct-06 20:11 
QuestionTEXTBOX HELP!!! Pin
dgap8-Nov-05 8:07
dgap8-Nov-05 8:07 
AnswerRe: TEXTBOX HELP!!! (REDO) Pin
dgap8-Nov-05 8:09
dgap8-Nov-05 8:09 
GeneralRe: TEXTBOX HELP!!! (REDO) Pin
Susan Hernandez9-Nov-05 14:52
Susan Hernandez9-Nov-05 14:52 
QuestionWork with ASCII code... Pin
ventomito8-Nov-05 8:04
ventomito8-Nov-05 8:04 
AnswerRe: Work with ASCII code... Pin
Dan Neely8-Nov-05 8:36
Dan Neely8-Nov-05 8:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.