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

  • Home
  • SEARCH
  • 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 4274136
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:48:24+00:00 2026-05-21T07:48:24+00:00

I am developing a Windows forms application which connects to a piece of hardware,

  • 0

I am developing a Windows forms application which connects to a piece of hardware, acquires a lot of data (~1 GSample/sec), processes it, and spits it out to the screen upon a button click. I am now trying to automate the process in a loop that can be started/stopped at any time so I can monitor it whilst tweaking the input to the acquisition hardware. I thinks it’s clear that I need to do this on a separate thread, but I’m having a heck of a time trying to do this in c++/cli – I have found a number of good examples using MFC, which is not supported by Express.

Specifically: My task is to press a button which is handled in Form1.h, to call a function in my main file Acquisition.cpp which contains the following code (currently an infinite loop)

void Form1::realTimeUpdate()  
{  
    // live is a boolean variable set by a button on the form
    while(live)  
    {  
        displayVariance(getVar(getQuadratures(100),nbrSamples));  
    }  
}  

I wish to execute this code in a separate thread so that the main program can listen for the user request to stop the operation. Without threading, I currently have to forcefully quit the program (or set it to run a fixed number of times) to stop it.

Is there any suggestions how I might go about running this code on a separate thread?

I’ve (unsuccessfully) tried a few things already:

  1. Modifying the example given in This Microsoft Example. Problem: requires /clr:oldSyntax option which is incompatible with the other 1300 lines of code in the program.

  2. Trying to do what I’d do in Java (Declare a global thread and start/stop it from any point in the code. Problem: Compiler won’t let me declare a global System::Threading.Thread

  3. this beautiful example. Problem: Requires MFC.

Any suggestions would be greatly appreciated!

  • 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-21T07:48:25+00:00Added an answer on May 21, 2026 at 7:48 am

    You can use a BackgroundWorker or a Thread to handle this. You’ll need to make sure that the portion of your work that updates the UI is marshaled back to the UI thread, however.

    Here is a tutorial on threading in C++/CLI.

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

Sidebar

Related Questions

I'm developing an Windows Forms application that requires me to call a separate program
I'm developing a web application and I need to mix Forms & Windows authentication
I'm developing a .NET Windows Forms application. I use the model-view-presenter design pattern, supervising
I am developing a windows forms application, in this application I am controlling a
I have been developing a C# windows form application in XP. It all works
I am developing a forms app (not web) for Windows Mobile, using .NET CF
I am developing a Windows .NET application (WinForms) and I need to simulate a
We're developing a windows mobile 6.1 application and would like to make the user
I'm developing an application that is reading and writing a lot (but synchronously, though)
When developing a stand alone application for windows, what type of application should i

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.