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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:59:15+00:00 2026-05-11T20:59:15+00:00

I have a GUI C# application that has a single button Start/Stop. Originally this

  • 0

I have a GUI C# application that has a single button Start/Stop.

Originally this GUI was creating a single instance of a class that queries a database and performs some actions if there are results and gets a single “task” at a time from the database.

I was then asked to try to utilize all the computing power on some of the 8 core systems. Using the number of processors I figure I can create that number of instances of my class and run them all and come pretty close to using a fair ammount of the computing power.

Environment.ProccessorCount;

Using this value, in the GUI form, I have been trying to go through a loop ProccessorCount number of times and start a new thread that calls a “doWork” type method in the class. Then Sleep for 1 second (to ensure the initial query gets through) and then proceed to the next part of the loop.

I kept on having issues with this however because it seemed to wait until the loop was completed to start the queries leading to a collision of some sort (getting the same value from the MySQL database).

In the main form, once it starts the “workers” it then changes the button text to STOP and if the button is hit again, it should execute on each “worker” a “stopWork” method.

Does what I am trying to accomplish make sense? Is there a better way to do this (that doesn’t involve restructuring the worker class)?

  • 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-11T20:59:16+00:00Added an answer on May 11, 2026 at 8:59 pm

    Restructure your design so you have one thread running in the background checking your database for work to do.

    When it finds work to do, spawn a new thread for each work item.

    Don’t forget to use synchronization tools, such as semaphores and mutexes, for the key limited resources. Fine tuning the synchronization is worth your time.

    You could also experiment with the maximum number of worker threads – my guess is that it would be a few over your current number of processors.

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

Sidebar

Related Questions

I have a windows application which has a complex GUI that I would like
I have a GUI application that has a ListView. It is used to show
I have a C# Application that has a GUI and has its output type
I have a Windows GUI application that's using the Qt framework (currently version 3.3.5,
I have a Qt application that has two threads: the main thread that handles
My use case is very simple : I have a GUI application, and inside
I have to build a GUI application on Windows Mobile, and would like it
In our application we sometimes have to make minor GUI modifications for different customers:
Say you have an application divided into 3-tiers: GUI, business logic, and data access.
Does MSTest have standalone GUI similar to nUnit that lets me use it and

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.