473,379 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Ok... very dumb question. static void Main()

I am trying to move my Main() procedure out of a startup form and into it's
own class. I've updated the app settings to use the "Globals" class (which
contains the main form). Here's what I have:

[STAThread]
static void Main()
{
Application.Run();
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
}

This results in nothing happening (no forms are shown). If I remove
Application.Run(); the two forms briefly flash and the app closes. There
must be something I don't understand about what Application.Run does? I
don't want to pass it a form to create beacuse that's what I'm trying to
prevent in the first place.

Thanks for any help.

-D
Nov 15 '05 #1
3 8547
Application.Run doesn't return until the app finishes

JIM
"MC D" <as***@earthtalk.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I am trying to move my Main() procedure out of a startup form and into it's own class. I've updated the app settings to use the "Globals" class (which contains the main form). Here's what I have:

[STAThread]
static void Main()
{
Application.Run();
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
}

This results in nothing happening (no forms are shown). If I remove
Application.Run(); the two forms briefly flash and the app closes. There
must be something I don't understand about what Application.Run does? I
don't want to pass it a form to create beacuse that's what I'm trying to
prevent in the first place.

Thanks for any help.

-D

Nov 15 '05 #2
MC D,
The Application.Run is a 'message pump', it does not return until
Application.Exit is called. When you pass a form to this method, an event
handler is added to the Form.Closed event, this handler calls
Application.Exit.

For your forms to display and function correctly, you need to call
Application.Run. To exit your app correctly you will need to call
Application.Exit (remember to call Application.Exit!).

To get your Main to work, put Application.Run after you show your two forms.
[STAThread]
static void Main()
{
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
Application.Run();
}
Now! what am I forgetting ;-)

Hope this helps
Jay

"MC D" <as***@earthtalk.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl... I am trying to move my Main() procedure out of a startup form and into it's own class. I've updated the app settings to use the "Globals" class (which contains the main form). Here's what I have:

[STAThread]
static void Main()
{
Application.Run();
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
}

This results in nothing happening (no forms are shown). If I remove
Application.Run(); the two forms briefly flash and the app closes. There
must be something I don't understand about what Application.Run does? I
don't want to pass it a form to create beacuse that's what I'm trying to
prevent in the first place.

Thanks for any help.

-D

Nov 15 '05 #3
Ah! That makes sense now. Thanks Jay!

-D
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
MC D,
The Application.Run is a 'message pump', it does not return until
Application.Exit is called. When you pass a form to this method, an event
handler is added to the Form.Closed event, this handler calls
Application.Exit.

For your forms to display and function correctly, you need to call
Application.Run. To exit your app correctly you will need to call
Application.Exit (remember to call Application.Exit!).

To get your Main to work, put Application.Run after you show your two forms.
[STAThread]
static void Main()
{
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
Application.Run();
}


Now! what am I forgetting ;-)

Hope this helps
Jay

"MC D" <as***@earthtalk.com> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
I am trying to move my Main() procedure out of a startup form and into

it's
own class. I've updated the app settings to use the "Globals" class

(which
contains the main form). Here's what I have:

[STAThread]
static void Main()
{
Application.Run();
frmSplash splashForm = new frmSplash();
splashForm.Show();
splashForm.lblStatus.Text = "Loading Preferences...";
//loadPrefs();
hndMainForm = new mainForm();
hndMainForm.Show();
}

This results in nothing happening (no forms are shown). If I remove
Application.Run(); the two forms briefly flash and the app closes. There must be something I don't understand about what Application.Run does? I
don't want to pass it a form to create beacuse that's what I'm trying to
prevent in the first place.

Thanks for any help.

-D


Nov 15 '05 #4

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

Similar topics

11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
10
by: PCHOME | last post by:
Hi! Would someone please help me thess C error(in gcc on Linux)? The compiler continues to give me: readLP.o: In function `Input_Problem': readLP.o(.text+0x0): multiple definition of...
12
by: Taylor | last post by:
I'm trying to understand inheritance. I'd like to make my own type of IPAddress lets call it myIp. The following gives me CS0029 error: Cannot implicitly convert type 'System.Net.IPAddress' to...
11
by: dhnriverside | last post by:
Hi peeps Ok, so I thought I'd have a go at making a console app in VS2k5... I haven't written any windows apps for years, let alone dos apps (been web programming) and I've hit a dumb error... ...
4
by: Doug Handler | last post by:
Hi, I've developed a plug-in application that basically is constructed of 2 pieces 1). the "main framework" 2). channels. Using Reflection in the Main Framework, i dynamically load Channels. ...
9
by: Justin M. Keyes | last post by:
Hi, Please read carefully before assuming that this is the same old question about string concatenation in C#! It is well-known that the following concatenation produces multiple immutable...
2
by: Jamey Bon | last post by:
I am a C# newbie. I am having a tough time with several issues of scope and visibility. In short, why can't I see any of the elements of Form1 (the base form generated by the "Windows...
7
by: Codeseeker99 | last post by:
I am new to java and I am trying to learn how to to reduce lines of code that are redundant in a simple file I made. I am trying to figure out how to reduce this code down to 13 methods not including...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.