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

  • Home
  • SEARCH
  • 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 425799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:24:57+00:00 2026-05-12T19:24:57+00:00

I have an array of threads, and I want to Join them all with

  • 0

I have an array of threads, and I want to Join them all with a timeout (i.e. see if they have all finished within a certain timeout). I’m looking for something equivalent to WaitForMultipleObjects or a way of passing the thread handles into WaitHandle.WaitAll, but I can’t seem to find anything in the BCL that does what I want.

I can of course loop through all the threads (see below), but it means that the overall function could take timeout * threads.Count to return.

private Thread[] threads;

public bool HaveAllThreadsFinished(Timespan timeout)
{
     foreach (var thread in threads)
     {
        if (!thread.Join(timeout))
        {
            return false;
        }                
     }
     return true;
}
  • 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-12T19:24:58+00:00Added an answer on May 12, 2026 at 7:24 pm

    But within this loop you can decrease timeout value:

    private Thread[] threads;
    
    public bool HaveAllThreadsFinished(Timespan timeout)
    {
         foreach (var thread in threads)
         {
            Stopwatch sw = Stopwatch.StartNew();
            if (!thread.Join(timeout))
            {
                return false;
            }
            sw.Stop();
            timeout -= Timespan.FromMiliseconds(sw.ElapsedMiliseconds);                
         }
         return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an array of threads and started all of them. How to
For example I have array of (x,y) points and I want to organize them
I have some Thread count pCount and I have some float[] array. I want
Suppose I have an array of data, can 2 threads safely write to different
I am programming in UPC and have an array shared between two threads. Each
I have an array of UIButtons . What I want to do is with
I have a large array in RAM and want to read data from it
This question will sound like a newbie but i have gone through all threads
I have a kernel which produces an array of result values and I want
I have a struck with an array of pthread pointers. Each thread is meant

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.