Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8638975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:52:47+00:00 2026-06-12T10:52:47+00:00

This is a situation where there is always more work to be done since

  • 0

This is a situation where there is always more work to be done since there is always a queue of emails to process. I want to make sure that any exceptions produced in the parallel.foreach will be logged. The examples I’ve found all wait until the queue (in this case MailToDownload) is finished before I can handle the exceptions. In my situation, how should I handle exceptions?

Below is a basic example of how I’m writing my methods. The first task pulls a list of emails to be pulled from the database. Every time an email account gets mail, the email address is inserted into the table, so there is always data.

Sub Main()
    Dim MailToDownload As New BlockingCollection(Of myMail)

    Task.Factory.StartNew(Sub()
                            For i As Integer = 0 To 99
                                MailToDownload.Add(New myMail With {.id = i})
                                System.Threading.Thread.Sleep(1000)
                            Next
                          End Sub)

    Task.Factory.StartNew(Sub()
                            Dim options As ParallelOptions = New ParallelOptions With {.MaxDegreeOfParallelism = 16}
                            Parallel.ForEach(MailToDownload.GetConsumingPartitioner(), options, Sub(item) doSomething(item))
                          End Sub)
End Sub

I’m thinking I should just handle all exceptions by loading them into another blockingcollection and spawn a different thread to handle those.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:52:49+00:00Added an answer on June 12, 2026 at 10:52 am

    I ended up putting the exceptions into a blocking collection and put a timer in another thread to periodically process the exceptions. It works quite well in a situation where the processing on the blocking collection never ends.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a process question, so there may be more than one right answer.
I have this situation: There are a login page with a login form (form
is there any way how in this situation insert and update DB with single
Situation is like this: There are independent 5 services. Each service consists of a
I have this situation where I want to display a list of Administration objects
I am sure there is a good way of solving this, but it's something
I was just reading this thread and it occurred to me that there is
In this situation I have two models, Comment and Score. The relationship is defined
I have this situation: $(#button).toggle(function(){ $(#window).animate({top:'0%'},1000); },function(){ $(#window).animate({top:'-100%'},1000); }); but I need change it
I have this situation: http://jsfiddle.net/bRDgK/3/ In this situation I have a modal dialog with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.