Solved

Error handling in a multithreaded environment (.NET)

Posted on 2006-06-15
4
231 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 300 total points
ID: 16911339
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Header Font Size in Grid View 6 50
Convert VB web project to C# 3 66
How to set focus on a dynamic control 18 52
GET INFO ABOUT WHAT THE PRINTER IS DOING ? 11 76
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

739 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