Exceptions and Parallel Loops(www.blackwasp.co.uk)

submitted by BlackWaspBlackWasp(4212) 8 months, 18 days ago

The sixth part of the Parallel Programming in .NET tutorial is the last instalment that examines the parallel loops. This article discusses how exceptions are thrown by code within a parallel loop and how they can be handled.

4 comments |category: |Views: 14

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by dpetersondpeterson(4397) 8 months, 18 days ago 0

Thanks for the article, none of the write-ups on the new parallel extensions that I've seen have covered exceptions.
How would you go about signaling the other threads that they should stop gracefully if you catch an aggregate exception? Or is there no way to tell scheduled iterations to stop/abort gracefully?

Reply

posted by BlackWaspBlackWasp(4212) 8 months, 17 days ago 0

You are most welcome :D

I'm going to write an article outside of the tutorial about this at some point. The best way in a loop is to use parallel loop state (also mentioned in the tutorial - look at the article about terminating loops early). There's a property named IsExceptional that you can look at to see if another parallel iteration has raised an exception. In long-runnning iterations you can check for this and terminate early using Stop.

Reply

posted by dpetersondpeterson(4397) replied to BlackWaspBlackWasp(4212), 8 months, 17 days ago 0

Be sure to post it here when you're finished with it, I'm looking forward to reading it!

Reply

posted by BlackWaspBlackWasp(4212) replied to dpetersondpeterson(4397), 8 months, 16 days ago 0

Will do. You can also keep an eye on the RSS feed.

Reply

information Login or create an account to comment on this story