CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2004
    Posts
    1,361

    Exceptions and Threads

    If you start a thread, and somewhere in the thread an exception is thrown, but not caught in that thread, what happens?

    Something like:
    Code:
    try
    {
       MyThread.Start();
    }
    catch
    {
    }

    Does the exception propagate up to the thread or process that started it?

    Or does your program crash with an unhandled exception error?

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Exceptions and Threads

    Well I woulda thought otherwise, but it appears that if a thread doesn't have an exception handler in C# (.net 2.0+)and an exception goes unhandled, it kills the whole app. Apparently a global exception handler isnt good enough in C#. AKA each thread must handle its own exceptions in C#.

    http://www.albahari.com/threading/
    Last edited by ahoodin; October 8th, 2008 at 01:51 PM.
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Sep 2004
    Posts
    1,361

    Re: Exceptions and Threads

    Thanks for that answer, it is what I suspected. Ill review the link you sent me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured