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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:25:34+00:00 2026-06-09T01:25:34+00:00

Decided to not use any timers. What i did is simpler. Added a backgroundworker.

  • 0

Decided to not use any timers.
What i did is simpler.

Added a backgroundworker.
Added a Shown event the Shown event fire after all the constructor have been loaded.
In the Shown event im starting the backgroundworker async.

In the backgroundworker DoWork im doing:

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            while(true)
            {
                cpuView();
                gpuView();
                Thread.Sleep(1000);
            }
        }
  • 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-09T01:25:36+00:00Added an answer on June 9, 2026 at 1:25 am

    In this case it’s better to use two System.Threading.Timer and execute your cpu-intensive operations in these two threads. Please note that you must access controls with BeginInvoke. You can encapsulate those accesses into properties setter or even better pull them out to a view model class.

    public class MyForm : Form
    {
        private System.Threading.Timer gpuUpdateTimer;
        private System.Threading.Timer cpuUpdateTimer;
    
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
    
            if (!DesignMode)
            {
                gpuUpdateTimer = new System.Threading.Timer(UpdateGpuView, null, 0, 1000);
                cpuUpdateTimer = new System.Threading.Timer(UpdateCpuView, null, 0, 100);
            }
        }
    
        private string GpuText
        {
            set
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(() => gpuLabel.Text = value), null);
                }
            }
        }
    
        private string TemperatureLabel
        {
            set
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new Action(() => temperatureLabel.Text = value), null);
                }
            }
        }
    
        private void UpdateCpuView(object state)
        {
            // do your stuff here
            // 
            // do not access control directly, use BeginInvoke!
            TemperatureLabel = sensor.Value.ToString() + "c" // whatever
        }
    
        private void UpdateGpuView(object state)
        {
            // do your stuff here
            // 
            // do not access control directly, use BeginInvoke!
            GpuText = sensor.Value.ToString() + "c";  // whatever
        }
    
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (cpuTimer != null)
                {
                    cpuTimer.Dispose();
                }
                if (gpuTimer != null)
                {
                    gpuTimer.Dispose();
                }
            }
    
            base.Dispose(disposing);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I decided not to use an orm and going to use straight ADO.NET for
I am currently working on a ASP.NET AJAX application. Having decided to not use
I was going to use the program called Tiled , but decided not to
My team recently decided not to use the trunk branch that is typical of
Update : Been some time. But back then decided not to use Mongoose. Main
I know you shouldn't use this to decide whether or not to change an
I was evaluating the Enterprise IDE plugin for Eclipse, and ultimately decided not to
I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to
My company has decided to develop ebook DRM platform. The platform does not have
I've decided to develop a database driven web app, but I'm not sure where

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.