Returning Exceptions from Thread to Main GUI and Throwing Modal Dialog Box RRS feed

  • Question

  • If I have a thread running and it encounters (and handles) an exception, how can I return that information to the main gui such that the Main Form can throw a modal dialog box?  Are there any obvious patterns for this that I'm missing?  Please include the code, if you can.

    Monday, November 29, 2010 11:31 PM


  • You have to store it somewhere that will outlive the thread and send it to the main thread.

    For an example, see the source code of BackgroundWorker Class in .Net Refector.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by eryang Tuesday, December 7, 2010 8:18 AM
    Tuesday, November 30, 2010 12:47 AM