Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Error handling in a multithreaded environment (.NET)

Posted on 2006-06-15
4
Medium Priority
?
234 Views
Last Modified: 2010-04-16
Hi Experts,

      I am kind of new to .NET and multithreading in general.  I am looking for info on how to do error handling in a multithreaded environment.  I need to know the appropriate ways to:

        - stop a worker thread from the main thread (in case an error outside of the worker thread happened, or user requested it to be stopped)
        - General error handling

Thanks,
axnst2
0
Comment
Question by:axnst2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:axnst2
ID: 16911165
I can think of ways of doing it, but what's the excepted/appropriate way of doing it?
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 1200 total points
ID: 16911339
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 800 total points
ID: 16911443
I don't see error handling in that example.  The important point is that exceptions can't cross thread boundaries.

As in the example, it is convenient to have each thread running in an instance of some worker class, LongProcess.  So you'll have that thread/instance catch exceptions locally, and set a member variable to indicate the error status.  When the caller detects the thread is done, it can access the member variable (via a getter).
0
 

Author Comment

by:axnst2
ID: 16911452
That's exactly what I was looking for.  Thanks Alex!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 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