Click here to Skip to main content
15,917,636 members
Home / Discussions / C#
   

C#

 
Questionconst member function Pin
Maddie from Dartford8-Jan-07 18:00
Maddie from Dartford8-Jan-07 18:00 
AnswerRe: const member function Pin
Christian Graus8-Jan-07 18:04
protectorChristian Graus8-Jan-07 18:04 
GeneralRe: const member function Pin
led mike8-Jan-07 18:25
led mike8-Jan-07 18:25 
AnswerRe: const member function Pin
Guffa8-Jan-07 19:02
Guffa8-Jan-07 19:02 
GeneralRe: const member function Pin
CPallini8-Jan-07 21:17
mveCPallini8-Jan-07 21:17 
QuestionC# map template equivalent? Pin
swjam8-Jan-07 17:33
swjam8-Jan-07 17:33 
AnswerRe: C# map template equivalent? Pin
Christian Graus8-Jan-07 18:01
protectorChristian Graus8-Jan-07 18:01 
QuestionTerminating an Application ? Pin
Mike Bluett8-Jan-07 15:40
Mike Bluett8-Jan-07 15:40 
Talking about the designers of C# making something complicated or what!

I have built a LogViewer application and my objective is to terminate the application if it determines there are no log files to display or if the logfile is in use by another application.

I run the application from Main as follows:

Application.Run(new MainForm());

In MainForm, it first does InitializeComponent, then it Populates the LogSelector with some user choices and then it adds logging info to the appropriate control if a log file is available (DisplayLogInfo).

If DisplayLogInfo detects that no logfile is available or the logfile is being used by another app, I want LogViewer to not show any form and to terminate.

I have tried this.Hide(). I have tried Application.Exit(). I have tried to make the form invisible by setting this.Visible to false. I have tried this.Dispose(), but then I get an unhandled exception and would rather not handle the exception by ignoring it.

Regardless, the form always displays and I have to close the app via closing the Window by the Close button.

Can anyone suggest a way to get this to work.

I would rather not rewrite the app. so that it checks for the logfile before running InitializeComponent as I believe there must be a way to accomplish the task as I have written it and I would like to learn how it can be done.

Comments?
AnswerRe: Terminating an Application ? Pin
Lisa Jorgensen8-Jan-07 16:03
Lisa Jorgensen8-Jan-07 16:03 
GeneralRe: Terminating an Application ? Pin
Mike Bluett8-Jan-07 16:52
Mike Bluett8-Jan-07 16:52 
AnswerRe: Terminating an Application ? Pin
Lisa Jorgensen8-Jan-07 20:11
Lisa Jorgensen8-Jan-07 20:11 
QuestionDisable Window Close Pin
MasterYoda798-Jan-07 14:07
MasterYoda798-Jan-07 14:07 
AnswerRe: Disable Window Close Pin
Luc Pattyn8-Jan-07 14:20
sitebuilderLuc Pattyn8-Jan-07 14:20 
GeneralRe: Disable Window Close Pin
MasterYoda799-Jan-07 6:08
MasterYoda799-Jan-07 6:08 
QuestionHow create "always on bottom" apps? Pin
noemailz8-Jan-07 11:56
noemailz8-Jan-07 11:56 
AnswerRe: How create "always on bottom" apps? Pin
Ravi Bhavnani8-Jan-07 12:25
professionalRavi Bhavnani8-Jan-07 12:25 
GeneralRe: How create "always on bottom" apps? Pin
Stephen Hewitt8-Jan-07 15:42
Stephen Hewitt8-Jan-07 15:42 
GeneralRe: How create "always on bottom" apps? Pin
Ravi Bhavnani8-Jan-07 16:27
professionalRavi Bhavnani8-Jan-07 16:27 
QuestionWindows form and controls not handling focus properly Pin
likefood8-Jan-07 11:42
likefood8-Jan-07 11:42 
AnswerRe: Windows form and controls not handling focus properly Pin
likefood8-Jan-07 11:58
likefood8-Jan-07 11:58 
QuestionWindows closing itself in a thread Pin
suck1238-Jan-07 11:21
suck1238-Jan-07 11:21 
AnswerRe: Windows closing itself in a thread Pin
Judah Gabriel Himango8-Jan-07 12:41
sponsorJudah Gabriel Himango8-Jan-07 12:41 
GeneralRe: Windows closing itself in a thread Pin
suck1238-Jan-07 19:22
suck1238-Jan-07 19:22 
GeneralRe: Windows closing itself in a thread Pin
Mircea Puiu8-Jan-07 23:54
Mircea Puiu8-Jan-07 23:54 
GeneralRe: Windows closing itself in a thread Pin
suck1239-Jan-07 2:18
suck1239-Jan-07 2:18 

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.