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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:41:43+00:00 2026-05-28T03:41:43+00:00

The problem is that the program throws an exception. After creating multiple threads. How

  • 0

The problem is that the program throws an exception. After creating multiple threads. How can we limit the number of threads to be created in the loop?

 for (int jrCnt = rCnt; jrCnt <= arrayTable.GetUpperBound(0); jrCnt++)
                {
                    /* bla bla bla */

                    if ((!string.IsNullOrEmpty(prcI.name)) &&
                        (prcI.prc != 0))
                    {
                        /*bla bla bla*/

                        var thread = // run updade or add
                                                    new Thread(() =>
                                                    {

                                                        if (!Accessor.AddProductUpdateProduct(prcI)) _updateCounter++;
                                                        _countadd++;

                                                    });
                        thread.Name = "Add_or_update-no_" + thread.ManagedThreadId;
                        thread.Priority = ThreadPriority.Lowest;

                        thread.Start();
                    }

Some clarification.

Here is the loop starts top n number of times. Once I add Threadpool this loop is very fast. Therefore Threadpool triggered 180 times. I apologize for my English.

for (int i = sbook; i < book; i++)
            {
                dt = Accessor.ImporterXls(_path, i);// array for method

                ConstructWithBook(dt, rCnt, sbook, book, priceSelect, nametov, pricetov,
                                 categorytov);
            }
  • 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-28T03:41:43+00:00Added an answer on May 28, 2026 at 3:41 am

    Try using a ThreadPool, MSDN Thread Pool Class Description

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

Sidebar

Related Questions

I'm almost finished with my program, but I have one problem that I can't
with my RCP program I have the problem that I want to have more
When I write a C program, I encountered a problem that is as follows:
This is my problem. I have a program that has to run in a
We've run into a thorny problem. We are writing a c++ program that receives
I am writing a program in Python, and I realized that a problem I
I have my program that can draw rectangles. I have two problems I can't
I am now debugging a program that utilizes many different threads. There is an
I have an application that seems to throw exceptions only after the program has
My program creates some threads for some tasks. My code is like this: Dictionary<int,

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.