Re: Application.Exit problem
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 06/17/04
- Next message: Morten Wennevik: "Re: Finding value of win listBox?"
- Previous message: Chuck: "Re: Application.Exit problem"
- In reply to: Chuck: "Application.Exit problem"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Jun 2004 20:06:29 +0100
Chuck <ceatley@austin.rr.com> wrote:
> I need to abort execution during start up, while the constructor called by
> Application.Run is executing.
>
> If the database fails to connect during my application's startup I want to
> display a message (no problem here) and then abort the program. However,
> after the attached code executes I end up with my main form and a wait
> cursor! If I click on the X the form closes. Boss doesn't think an
> unhandled exception will impress our customers :) Can't say that I
> disagree.
Well, three options:
1) Don't do the connection within the form construction. Do it before
you construct the form, but while the splash screen is up.
2) Handle the exception so that customers don't see an unhandled
exception. Don't forget that until your constructor has returned,
Application.Run hasn't been called, which is why Application.Exit isn't
working. A simple try/catch in your Main method should work here, I
believe.
3) Use Environment.Exit instead.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Morten Wennevik: "Re: Finding value of win listBox?"
- Previous message: Chuck: "Re: Application.Exit problem"
- In reply to: Chuck: "Application.Exit problem"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|