Click here to Skip to main content
15,908,274 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to use the printDialogBox? Pin
quiteSmart24-Oct-06 22:43
quiteSmart24-Oct-06 22:43 
QuestionHow can I add the assembly Microsoft.Office.Interop.Outlook? Pin
OctopusThu24-Oct-06 19:26
OctopusThu24-Oct-06 19:26 
AnswerRe: How can I add the assembly Microsoft.Office.Interop.Outlook? Pin
OctopusThu24-Oct-06 19:36
OctopusThu24-Oct-06 19:36 
QuestionCustom Draw TreeView problem - Painted "+" got overriden Pin
DiegoValdevino24-Oct-06 19:18
DiegoValdevino24-Oct-06 19:18 
QuestionCustom UserControl shape problem... Pin
Kasic Slobodan24-Oct-06 16:08
Kasic Slobodan24-Oct-06 16:08 
AnswerRe: Custom UserControl shape problem... Pin
Kasic Slobodan27-Oct-06 7:31
Kasic Slobodan27-Oct-06 7:31 
QuestionApplication.Exit(); not working in the form constructor, why? Pin
AngryC24-Oct-06 14:57
AngryC24-Oct-06 14:57 
AnswerRe: Application.Exit(); not working in the form constructor, why? Pin
Nader Elshehabi24-Oct-06 15:22
Nader Elshehabi24-Oct-06 15:22 
Hello

I believe you are making the famous scenario of checking a condition -maybe login or something- at the start of your application, if(false) => Exit(). Right?

Well if you take a look ate Program.cs file where the main method exists, you'd see this line
Application.Run(new MyForm());


So actually it excutes more like this:
MyForm temp = new MyForm()
Application.Run(temp)
//Then temp dies here

Well, not exactly but I made it this way to illustrate that your constructor must return first before the Run() method actually gets called, and of course calling the Exit() method is useless if the Run() didn't get excuted first.

Suggested solution:
Simple; Make the Application.Exit() call in your Form_Load event if applicable.



RegardsRose | [Rose]

GeneralRe: Application.Exit(); not working in the form constructor, why? Pin
AngryC24-Oct-06 16:31
AngryC24-Oct-06 16:31 
GeneralRe: Application.Exit(); not working in the form constructor, why? Pin
EricT.25-Nov-10 7:27
EricT.25-Nov-10 7:27 
QuestionSearch for statements in CS files. Pin
Alex Iagovsky24-Oct-06 14:34
Alex Iagovsky24-Oct-06 14:34 
AnswerRe: Search for statements in CS files. Pin
Nader Elshehabi24-Oct-06 15:29
Nader Elshehabi24-Oct-06 15:29 
GeneralRe: Search for statements in CS files. Pin
Alex Iagovsky25-Oct-06 3:19
Alex Iagovsky25-Oct-06 3:19 
QuestionForms Pin
m.m._200724-Oct-06 14:07
m.m._200724-Oct-06 14:07 
AnswerRe: Forms [modified] Pin
Nader Elshehabi24-Oct-06 15:40
Nader Elshehabi24-Oct-06 15:40 
AnswerRe: Forms Pin
phenix-burn24-Oct-06 15:42
phenix-burn24-Oct-06 15:42 
QuestionSocket class Poll method and POP3 client Pin
Martin Lachowicz24-Oct-06 13:00
Martin Lachowicz24-Oct-06 13:00 
QuestionCounting months between dates? Pin
rbaut24-Oct-06 12:08
rbaut24-Oct-06 12:08 
AnswerRe: Counting months between dates? Pin
Guffa24-Oct-06 12:15
Guffa24-Oct-06 12:15 
QuestionWhy doesn't the left mouse button work... [modified] Pin
new_phoenix24-Oct-06 11:19
new_phoenix24-Oct-06 11:19 
QuestionCollectionEditor and Generics Pin
Jamie Nordmeyer24-Oct-06 10:43
Jamie Nordmeyer24-Oct-06 10:43 
QuestionNeed to access value from app.config file Pin
Shilpa124-Oct-06 10:21
Shilpa124-Oct-06 10:21 
AnswerRe: Need to access value from app.config file Pin
Craig G Fraser24-Oct-06 20:39
Craig G Fraser24-Oct-06 20:39 
Questionrandom numbers Pin
Jad Jadallah24-Oct-06 10:18
Jad Jadallah24-Oct-06 10:18 
AnswerRe: random numbers Pin
Jim Conigliaro24-Oct-06 10:53
Jim Conigliaro24-Oct-06 10:53 

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.