Click here to Skip to main content
15,890,185 members
Home / Discussions / C#
   

C#

 
GeneralRe: application uses all the memory Pin
Chen Pang17-Feb-04 23:13
Chen Pang17-Feb-04 23:13 
GeneralRe: application uses all the memory Pin
Heath Stewart18-Feb-04 3:55
protectorHeath Stewart18-Feb-04 3:55 
Generalclosing the main form after loading another form Pin
killermoses16-Feb-04 19:31
killermoses16-Feb-04 19:31 
GeneralRe: closing the main form after loading another form Pin
John Kuhn16-Feb-04 19:38
John Kuhn16-Feb-04 19:38 
GeneralRe: closing the main form after loading another form Pin
obelisk2916-Feb-04 19:48
obelisk2916-Feb-04 19:48 
GeneralRe: closing the main form after loading another form Pin
killermoses17-Feb-04 2:02
killermoses17-Feb-04 2:02 
GeneralRe: closing the main form after loading another form Pin
Heath Stewart17-Feb-04 5:26
protectorHeath Stewart17-Feb-04 5:26 
GeneralRe: closing the main form after loading another form Pin
Charlie Williams17-Feb-04 4:19
Charlie Williams17-Feb-04 4:19 
If you're using VS.NET, your application entry point probably looks like this:
[STAThread]
static void Main() 
{
   Application.Run(new Form1());
}

This means that
1) this call will not return until Form1 has closed
2) the application will terminate immediately after Form1 is closed.

If you need to close Form1 have have the app keep plugging away, you can't rely on the VS.NET-generated code. Instead, you can write a class to handle showing the form(s) you need to show.

//Rediculously simple example
public class AppStarter{
   public AppStarter(){
     Form1 frm = new Form1();
     frm.Show(); 
   }
   [STAThread]
   public void Main(){
     Application.Run(new AppStarter());
   }
}


Now the application will run as long as the instance of AppStarter created in Main() is alive. You need to remember to call Application.Exit() when your last form closes or the app will never die, even if there's nothing on screen because the lifetime of the app is no longer directly related to the lifetime of the form.

Charlie

if(!curlies){ return; }
GeneralCalling Managed C++ code in a C# App Pin
granderson16-Feb-04 12:28
granderson16-Feb-04 12:28 
GeneralRe: Calling Managed C++ code in a C# App Pin
obelisk2916-Feb-04 19:41
obelisk2916-Feb-04 19:41 
GeneralMetrics 2 english 2 twips 2 whatever Pin
Tomaž Štih16-Feb-04 11:58
Tomaž Štih16-Feb-04 11:58 
GeneralRe: Metrics 2 english 2 twips 2 whatever Pin
Heath Stewart17-Feb-04 3:52
protectorHeath Stewart17-Feb-04 3:52 
GeneralPrinting from a webservice Pin
nathanreynolds16-Feb-04 11:31
nathanreynolds16-Feb-04 11:31 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 3:26
protectorHeath Stewart17-Feb-04 3:26 
GeneralRe: Printing from a webservice Pin
nathanreynolds17-Feb-04 10:55
nathanreynolds17-Feb-04 10:55 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 13:13
protectorHeath Stewart17-Feb-04 13:13 
GeneralRe: Printing from a webservice Pin
nathanreynolds17-Feb-04 16:27
nathanreynolds17-Feb-04 16:27 
GeneralRe: Printing from a webservice Pin
Heath Stewart17-Feb-04 19:32
protectorHeath Stewart17-Feb-04 19:32 
GeneralRe: Printing from a webservice Pin
nathanreynolds18-Feb-04 2:27
nathanreynolds18-Feb-04 2:27 
GeneralRe: Printing from a webservice Pin
Heath Stewart18-Feb-04 4:11
protectorHeath Stewart18-Feb-04 4:11 
GeneralA GDI+ newbie problem Pin
cemlouis16-Feb-04 11:28
cemlouis16-Feb-04 11:28 
GeneralRe: A GDI+ newbie problem Pin
Charlie Williams16-Feb-04 16:14
Charlie Williams16-Feb-04 16:14 
GeneralRe: A GDI+ newbie problem Pin
cemlouis17-Feb-04 3:50
cemlouis17-Feb-04 3:50 
GeneralFill 50% of a drawing with a color Pin
r916-Feb-04 9:32
r916-Feb-04 9:32 
GeneralRe: Fill 50% of a drawing with a color Pin
Heath Stewart16-Feb-04 9:45
protectorHeath Stewart16-Feb-04 9:45 

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.