Click here to Skip to main content
15,879,095 members
Home / Discussions / C#
   

C#

 
GeneralRe: "new" to hide base class implementation - is it useless? Pin
devvvy1-Feb-13 14:56
devvvy1-Feb-13 14:56 
QuestionCatching unhandled ThreadAbortException from Main? Pin
devvvy30-Jan-13 14:56
devvvy30-Jan-13 14:56 
AnswerRe: Catching unhandled ThreadAbortException from Main? Pin
Andy41130-Jan-13 22:37
Andy41130-Jan-13 22:37 
AnswerRe: Catching unhandled ThreadAbortException from Main? Pin
Shameel31-Jan-13 3:49
professionalShameel31-Jan-13 3:49 
AnswerRe: Catching unhandled ThreadAbortException from Main? Pin
jschell31-Jan-13 8:29
jschell31-Jan-13 8:29 
GeneralRe: Catching unhandled ThreadAbortException from Main? Pin
devvvy31-Jan-13 15:43
devvvy31-Jan-13 15:43 
GeneralRe: Catching unhandled ThreadAbortException from Main? Pin
jschell2-Feb-13 7:53
jschell2-Feb-13 7:53 
AnswerRe: Catching unhandled ThreadAbortException from Main? Pin
Keld Ølykke31-Jan-13 21:15
Keld Ølykke31-Jan-13 21:15 
I would expect some exceptions to be thrown within the threads and some thread related exceptions to be thrown back to the main thread; ThreadAbortException could be one of the later.

In the later case, I would expect the following code to catch all exception thrown within the main thread:

C#
/// <summary>
/// Main entry point.
/// </summary>
[STAThread]
[SuppressMessage("Microsoft.Usage", "CA1801")] // unused parameters
public static int Main(string[] args)
{
    Program program = new Program(); // winform

    do
    {
        try
        {
            program.Update(); // logic code
            Application.DoEvents(); // updates winform - inputs and drawing
        }
        catch (Exception exception)
        {
            if (program.Log.IsFatalEnabled)
            {
                program.Log.Fatal("Caught Unhandled Exception: " + exception);
            }
            break;
        }
    }
    while (program.StateCurrent != EProgramState.Shutdown
        && program.ExitCode == EProgramError.NoError);

    return (int)program.ExitCode;
}



If ThreadAbortException is thrown within the thread, I would look for a way to register my own thread main method and do similar wrapping in there.

Kind Regards,

Keld Ølykke
QuestionGo to finally in try block Pin
vanikanc30-Jan-13 7:25
vanikanc30-Jan-13 7:25 
AnswerRe: Go to finally in try block Pin
Jibesh30-Jan-13 7:35
professionalJibesh30-Jan-13 7:35 
GeneralRe: Go to finally in try block Pin
vanikanc30-Jan-13 7:37
vanikanc30-Jan-13 7:37 
GeneralRe: Go to finally in try block Pin
Jibesh30-Jan-13 7:41
professionalJibesh30-Jan-13 7:41 
GeneralRe: Go to finally in try block Pin
vanikanc30-Jan-13 7:42
vanikanc30-Jan-13 7:42 
GeneralRe: Go to finally in try block Pin
Jibesh30-Jan-13 7:44
professionalJibesh30-Jan-13 7:44 
GeneralRe: Go to finally in try block Pin
devvvy31-Jan-13 15:44
devvvy31-Jan-13 15:44 
AnswerRe: Go to finally in try block Pin
Eddy Vluggen30-Jan-13 7:45
professionalEddy Vluggen30-Jan-13 7:45 
AnswerRe: Go to finally in try block Pin
PIEBALDconsult30-Jan-13 7:53
mvePIEBALDconsult30-Jan-13 7:53 
AnswerRe: Go to finally in try block Pin
jschell30-Jan-13 8:04
jschell30-Jan-13 8:04 
AnswerRe: Go to finally in try block Pin
Abhinav S30-Jan-13 21:32
Abhinav S30-Jan-13 21:32 
AnswerRe: Go to finally in try block Pin
V.30-Jan-13 22:10
professionalV.30-Jan-13 22:10 
AnswerRe: Go to finally in try block Pin
Rahul Rajat Singh30-Jan-13 22:15
professionalRahul Rajat Singh30-Jan-13 22:15 
AnswerRe: Go to finally in try block Pin
Rahul Rajat Singh30-Jan-13 22:18
professionalRahul Rajat Singh30-Jan-13 22:18 
GeneralRe: Go to finally in try block Pin
devvvy31-Jan-13 15:46
devvvy31-Jan-13 15:46 
QuestionUnit Conversion Application - C#, IIS, ASP.NET 4.0, WCF, Windows form app Pin
MacRuturaj30-Jan-13 7:07
MacRuturaj30-Jan-13 7:07 
AnswerRe: Unit Conversion Application - C#, IIS, ASP.NET 4.0, WCF, Windows form app Pin
Ennis Ray Lynch, Jr.30-Jan-13 7:16
Ennis Ray Lynch, Jr.30-Jan-13 7:16 

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.