In my application, I am using the free NBug crash reporting library. In order to integrate it into your project you need to add these two lines in your Program.cs:
AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
Application.ThreadException += NBug.Handler.ThreadException;
However, I need to run a block of code in cases where my program crashes. This code needs to clean up some entries in a mysql database. I thought of simply adding extra event handles after the NBug ones:
AppDomain.CurrentDomain.UnhandledException += NBug.Handler.UnhandledException;
Application.ThreadException += NBug.Handler.ThreadException;
Application.ThreadException += new ThreadExceptionEventHandler(mysqlcleanup);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(mysqlcleanup1);
However in this case the program only performs the mysql cleanup events, and ignores the NBug ones. Is it even possible to have multiple exception handlers? I thought of editing the NBug source to run the mysql commands but that would mean attaching the mysql library to that project which is less than ideal.
Any ideas are very welcome.