Click here to Skip to main content
15,907,392 members
Home / Discussions / C#
   

C#

 
AnswerRe: Detect if control is being rendered in the forms designer ? Pin
Christian Graus8-Nov-05 14:54
protectorChristian Graus8-Nov-05 14:54 
GeneralRe: Detect if control is being rendered in the forms designer ? Pin
Jon Rista9-Nov-05 10:58
Jon Rista9-Nov-05 10:58 
GeneralRe: Detect if control is being rendered in the forms designer ? Pin
Christian Graus9-Nov-05 11:13
protectorChristian Graus9-Nov-05 11:13 
Questionhelp help help Pin
engriri20068-Nov-05 14:18
engriri20068-Nov-05 14:18 
AnswerRe: help help help Pin
Christian Graus8-Nov-05 14:23
protectorChristian Graus8-Nov-05 14:23 
GeneralRe: help help help Pin
Allah On Acid8-Nov-05 16:18
Allah On Acid8-Nov-05 16:18 
QuestionConsole.Writeline() in Forms Pin
MrEyes8-Nov-05 12:31
MrEyes8-Nov-05 12:31 
AnswerRe: Console.Writeline() in Forms Pin
S. Senthil Kumar8-Nov-05 19:38
S. Senthil Kumar8-Nov-05 19:38 
GeneralRe: Console.Writeline() in Forms Pin
MrEyes8-Nov-05 23:29
MrEyes8-Nov-05 23:29 
GeneralRe: Console.Writeline() in Forms Pin
S. Senthil Kumar9-Nov-05 21:40
S. Senthil Kumar9-Nov-05 21:40 
GeneralRe: Console.Writeline() in Forms Pin
S. Senthil Kumar9-Nov-05 21:42
S. Senthil Kumar9-Nov-05 21:42 
QuestionCreating Multiple Forms in my application Pin
kourvoisier8-Nov-05 12:06
kourvoisier8-Nov-05 12:06 
AnswerRe: Creating Multiple Forms in my application Pin
Christian Graus8-Nov-05 12:48
protectorChristian Graus8-Nov-05 12:48 
GeneralRe: Creating Multiple Forms in my application Pin
kourvoisier8-Nov-05 15:12
kourvoisier8-Nov-05 15:12 
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 

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.