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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:12:40+00:00 2026-05-28T20:12:40+00:00

I have C# windows form application that queries data from a connected device. I

  • 0

I have C# windows form application that queries data from a connected device. I currently start a System.Timer.Timer that is set to fire every 20ms and grab data from the connected tool. This works fine but of course the UI becomes unresponsive for updates of data counts, end-result of calcs on the data etc etc. I also display the data in a couple OpenGL windows so there is quite a bit going on.

_timer1 = new System.Timers.Timer{
Interval = Convert.ToDouble(txtElapse.Text),
Enabled = true};    
_timer1.Elapsed += Timer1Elapsed;

I then use then invalidate the form to redraw for the OpenGL and that is where all my calcs etc are carried out.

My question is to do with threading, basically at what point or to what object do I apply the thread logic to? The timer itself? If i do that I am unable to debug, it just sits there. I have done a fair amount of research to do with ThreadPools, Backgroundworker, Thread etc but nothing for this situation as I believe (mistakenly?) that the timer runs on its own thread by default.

  • 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-28T20:12:41+00:00Added an answer on May 28, 2026 at 8:12 pm

    A good rule of thumb is that anything that takes longer or could take longer than 50ms should be asynchronous. Your options for multi-threading depend on the target framework you are using, because in .NET 2-3.5 you have the standard asynchronous patterns (begin, end, invoke, callbacks), but in .NET 4 you have the Task Parallel Library.

    The BackgroundWorker is a wrapper for a asynchronous operation. So it would fit the bill for your operation. Considering you said you’ve done a fair amount of research on it, I won’t go in to details there.

    You can also spin off a thread and do thread-safe invokes to the UI.

    public void StartFooAsync() {
        Thread thread = new Thread(new ThreadStart(DoFooAsync));
        thread.IsBackground = true;
        thread.Start();
    }
    
    private void DoFooAsync() {
        while (m_Running) {
            // Do something
            Thread.Sleep(20ms); // Make the thread wait your 20ms
        }
    }
    

    You can also use the Task Parallel Library in .NET4.

    • 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 that has 2 Forms . From one form I
I have a windows form application that uses a Shared class to house all
I have a Windows form application that's consuming web services over https and is
I have a C# Windows Form application that contains a menu with this event:
I am using windows application and I have four combo boxes(comboeventname,combosendtype,comboType,comboschedule) in that form....
I have a Windows Form application built on a data model and a Windows
I have an Windows Form application that supplies the User Name, Domain, and Password
I have a Windows form application that users can log into. The application is
I have a form in a Windows form application that I want to display
I have a simple Windows Form application that is using the .net 3.5 compact

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.