Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8205713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:21:56+00:00 2026-06-07T08:21:56+00:00

I want to catch an exception in a thread A, then pass the exception

  • 0

I want to catch an exception in a thread A, then pass the exception object to a thread B, and throw it from thread B. Is that safe?

Thread A

try {
    // Code that throws exceptions
} catch (Exception e) {
    sendToOtherThread(e);
}

Thread B

Exception e = receiveException();
throw e;

EDIT

For sake of clarity: I understand how threading works, and how I should pass the object reference from one thread to the other. The question is more about is it safe to throw an exception object from one thread that did not create it or is there any problem with the class Exception itself or the way .NET handles it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:21:57+00:00Added an answer on June 7, 2026 at 8:21 am

    You can rethrow an exception received from another thread (for example, in a BackgroundWorker’s RunWorkerCompleted event handler), but it would be more usual to wrap it in another exception, to preserve the stack trace:

    private void backgroundWorker1_RunWorkerCompleted(
        object sender, RunWorkerCompletedEventArgs e)
    {
        // First, handle the case where an exception was thrown.
        if (e.Error != null)
        {
            throw new SomeException("... message ...", e.Error);
        }
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my below code and I want to catch the exception if any
Here is a snippet kit.insertHTML(doc, doc.getLength(), Hello, 0, 0, null); try{ Thread.sleep(1000); }catch(Exception e){}
I have a Queue object that I need to ensure is thread-safe. Would it
I want a way to check in my catch {} clause if the exception
I want to catch exceptions thrown by classes implementing Processor interface. In aspect I
i want to catch the data from server as an answer and alert it.
In .net the AggregateException class allows you to throw an exception containing multiple exceptions.
I need to catch exception out side the Thread which is occurred while Thread
I have the following code that sends a multicast message then waits for a
I want to catch a fancybox error (The requested content cannot be loaded. Please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.