Rich Newman

Top-level Exception Handling – Code Listing 4

        static void Main()
             Application.ThreadException += new ThreadExceptionEventHandler(new ThreadExceptionHandler().ApplicationThreadException);
             MainForm mainForm = null;
                 SplashScreen splash = new SplashScreen();
                 // Instantiate and initialize our main form here - we have exception handling in place
                 mainForm = new MainForm();
             catch (Exception e)
                 // You probably want something a little more sophisticated than this
                 MessageBox.Show(e.Message"An exception occurred:"MessageBoxButtons.OKMessageBoxIcon.Error);


  1. Okay if new ThreadExceptionHandler() is your own method for dealing with the exception, why does it not tie into the example? I mean what would I put in place of that. It does not compile on my system because my ide does not recognize new ThreadExceptionHandler()

    Comment by Mike Murphy — June 20, 2008 @ 7:56 pm

  2. Mike

    Please see the main article and code listing 1 which explain what I’m doing here. ThreadExceptionHandler is my own method, it is shown in code listing 1.

    Apologies for the code examples not being available for download: I wrote this article before I was set up for code downloads (WordPress doesn’t support that natively).


    Comment by richnewman — June 26, 2008 @ 2:15 pm

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: