Solved

Rethrowing exception from a thread

Posted on 2008-06-15
1
799 Views
Last Modified: 2012-03-15
Hi,

I created a web service that invokes  a thread that sends e-mails.
When the connection to the internet is terminated, this thread throws an exception.
I want to rethrow that exception to the client.
I tried to use the following code :

                         try
                        {
                            SmtpMail.Send(mailMessage);
                        }
                        catch (HttpException exc)
                        {
                            throw new HttpException(exc.GetHttpCode(), exc.Message);
                        }
but since we are in a thread, and nobody can catch the rethrown exception.
Please tell me how to throw an exception from a thread, so that it will can rethrown to the client.

Thanks
Michael
0
Comment
Question by:MichaelMarom
1 Comment
 
LVL 13

Accepted Solution

by:
iHadi earned 125 total points
Comment Utility
Try to invoke an event instead. Declare an event and invoke it instead of throwing an exception
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now