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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:20:13+00:00 2026-06-05T03:20:13+00:00

I started a Thread which collects around >500 records every 5 minutes.Then by foreach

  • 0

I started a Thread which collects around >500 records every 5 minutes.Then by foreach statement i created seperate background worker for each details obtained.I collect the data by checking the condition which is in Queue(‘QU’ in Db).While backgroundworkers Do_Work event i update the ‘QU’ status to ‘PR’.

BackgroundWorker bw1;
Collection collect = new Collection()
foreach (Transaction trans in transactionList)
                {
                    try
                    {
                        collect.TransactionDetails = trans;
                        bw1 = new BackgroundWorker();
                        bw1.DoWork += new DoWorkEventHandler(bw1_DoWork);
                        bw1.RunWorkerCompleted += new  RunWorkerCompletedEventHandler(bw1_RunWorkerCompleted);
                        bw1.RunWorkerAsync(collect);
                    }
                    catch
                    { }
                }

This is lengthy process so its must to run using backgroundworker.
My question is if this process takes more than Thread Sleep time to complete then same records with ‘QU’ status will be collected again.How can i understand the process is still running and make the Thread to wait for some more time till complete

  • 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-05T03:20:14+00:00Added an answer on June 5, 2026 at 3:20 am

    You need to somehow keep track of the running processes. The most basic way to do this would be to use a counter variable that you increment on creating a BackgroundWorker and decrement when it’s completed. You could then find out the number of still running BackgroundWorkers by simply looking at the variable’s value.

    If you’re on .NET 4, you also might want to have a look at the Task Parallel Library.

    Another thing: As far as i understand it you create a worker thread for over 500 items? That seems like a lot to me. Consider partitioning the workload into fewer larger pieces.

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

Sidebar

Related Questions

i need to use my application class inside my thread which is started with
I created an asynctask and in its doInBackground() method i started a thread like
Server has created a socket and bound to a port and started a thread
This class extends Thread and once it is created, the thread is started. This
I'm having this crash now and then, in a thread that is not started
I have written a thread which I've started using the start method but I'm
I have a daemon thread which is started when a page is opened. The
I have a background worker that is started on the main thread as shown
I want to cause the main thread (the thread started which runs main() )
I am using a thread which records the audio using AudioRecord class and placed

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.