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 7593451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:10:21+00:00 2026-05-30T21:10:21+00:00

In a project I’ve recently taken over, there is a call to a function

  • 0

In a project I’ve recently taken over, there is a call to a function which does some calculations; this is called in a row, several times (between 1 and 10 times usually).

While dr.read  ‘depending on a db call, loop 1 or more times
 Dim calc As New CalcClass
 Dim newDoStuff As New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf DoStuff))
 newDoStuff.Start(calc)
End while

Private Sub DoStuff(ByVal calc As Object)
‘do something that takes between 5-10 seconds
End sub

In order to speed this up, i am trying to add asynchronous processing (see above example), this works in my code, all tasks are done at the same time, but what I don’t understand is how to then wait for all these threads to finish (there is no set amount of threads, it can be between 1 and 10 depending on some other data) before finishing up with a final task that needs to run after all tasks are completed.

Can anyone suggest a way to do this – I’m looking for an easy way to basically say “O.k, all tasks are finished at this point, call another task”

Cliffs

  • Several tasks need to run at the same time (between 1 and 10)
  • Each task takes several seconds
  • Code currently works – it does them all at the same time
  • Once all tasks (between 1-10) are
    finished, fire off some other code (only when all tasks are finished) – stuck on best method to do the following
  • 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-05-30T21:10:22+00:00Added an answer on May 30, 2026 at 9:10 pm

    Put all your thread in an List

    Dim threads As new List(Of System.Threading.Thread)
    
    While dr.read  ‘depending on a db call, loop 1 or more times
        Dim calc As New CalcClass
        Dim newDoStuff As New System.Threading.Thread(New System.Threading.ParameterizedThreadStart(AddressOf DoStuff))
        threads.Add(newDoStuff)
        newDoStuff.Start(calc) 
    End while
    

    finally join all your threads

    For Each thread In threads Do
        thread.Join()
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently taken over a project from another consulting firm. I'm assuming this can
I have recently taken on a project in which I need to integrate with
We have taken over a .NET project recently and upon looking at the db
I was recently asked to take over a project in which waveform data is
I've recently taken over a MVVM project started by someone who's now left the
I've recently taken over a project, and the original developer has gone. I'm now
I have been looking through some code on an open source project recently and
I've become very addicted to Project Euler recently and am trying to do this
Project Euler I have recently begun to solve some of the Project Euler riddles.
I was recently reading this article by Dave Detlefs in which he presents a

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.