Solved

Error handling in a multithreaded environment (.NET)

Posted on 2006-06-15
4
227 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
  • 2
4 Comments
 

Author Comment

by:axnst2
Comment Utility
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
Comment Utility
0
 
LVL 21

Assisted Solution

by:mastoo
mastoo earned 200 total points
Comment Utility
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
Comment Utility
That's exactly what I was looking for.  Thanks Alex!
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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

10 Experts available now in Live!

Get 1:1 Help Now