how to handle exception in a second thread in asp.net?

L

lucy

Hi,
I'm working on a multi-threading web application. I'm using
Application_Error event to write exception detail to windows event log
to help debug. It seems exception happened in the second thread doesn't
fire this event. I tried to use trace.write() method. It doesn't seem
work either. I'm out of idea.

Any help is highly appreciated.

Lucy
 
B

Bruce Barker

multi thread asp.net apps is not usually a good idea as you can run into
scalling problems. if you start a thread, then its outside the asp.net
processing (as page processing is a asp.net thread calling a page method,
which uses a try/catch to implement Application_Error).

you background thread can write to the event log itself (it shoudl catch its
own errors). it could call back to the main thread, though you have to be
careful, as the main thread may switch during page processing. asp.net is
free to switch threads before calling a page methods like onload, onint, or
firing page events.

-- bruce (sqlwork.com)
 
L

lucy

Thank you bruce. It worked for me. I'm using the second thread for
email processing, since it's a really long process, I don't want to
hold the end user back. But there is one problem. How can I notify them
whether the process is successful or failure? As you said by the time
the second thread is complete, they may switch to other page already.

Any idea or direction?

thanks in advance.

Lucy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top