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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:16:22+00:00 2026-05-20T06:16:22+00:00

I have created a large amount of Task instances. I need to run them

  • 0

I have created a large amount of Task instances. I need to run them all, and wait for them all to complete. The problem is that I need to make sure that no more than X tasks are between “started” and “completed” at any given time; the tasks involve calls to other parties that have a restriction on the number of simultaneous calls. Since these restrictions are not based on my hardware, I can’t rely on any built in intelligent throttling; I need to enforce the limit strictly. I’ve been able to do this by having the tasks increment and decrement a shared variable in a thread-safe way, but it seems unnecessarily cumbersome. Is there a way that’s more built-in to the API directly, or an easy synchronization tool I’m missing?

  • 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-20T06:16:23+00:00Added an answer on May 20, 2026 at 6:16 am

    You have to create your own task scheduler, see How to: Create a Task Scheduler That Limits the Degree of Concurrency

    Edit: This requires more code than with Semaphore, but I have a feeling that this might perform better, because thread pool in which tasks are executed is unaware of your semaphore, but using TaskScheduler is playing by their rules.

    Edit 2: One of possible drawback of using semaphore is that thread pool might think that your task is doing IO operations and schedule them a lot at a time (so that they hang there and wait, because they don’t need CPU). Using TaskScheduler they will be scheduled exactly when there is place for them. It will definitely keep pool cleaner.

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

Sidebar

Related Questions

I have a large amount of Word documents that I need to parse. As
We have a large amount of apps. They all have a build.xml file located
I have created an object in Java, Named FOO. FOO contains a large amount
I have a stored procedure that is working with a large amount of data.
We have a java program that requires a large amount of heap space -
I have a large amount of data to process in c++ and find that
I have a large amount of data that I am pulling from an xml
I have an unusual project that I need to display large sets of questions
I have created a QTextBrowser to display a large amount of data (actually displaying
I have created a large Visual C++ 10.0 project which builds nicely within the

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.