Visual C++ Thread

Hello All,
I am not an expert in C++ programmer, but I have done some simple programming before. I would really appreciate some help.

I have written a .NET program, using Windows form Application.
My application is fairly simple.
Basically, I have two simple buttons on my form.
When the form is first loaded, I set up a global variable (bool run = true).

And my first button is essentially a very simple while loop.

// do some code

And what I want to do, is have the second button set the value of the boolean to false (bool run = false).

But, once I clicked the first button, I cannot even touch the second button!

I have read quite about this, and I think my solution is to use a multi-threading.
I have found some example codes on line for multi-threading, and I tried to incorporate those, but I don't know why I cannot get it to work. Once I click button #1, there is no way for me to be able to click button #2.

I would really appreciate some help.


Besides this being a C++ forum and not a .NET or C# or C++/CLI forum, your problem is that you shouldn't use a loop like that for buttons. You need to use event handling, not multithreading.
Last edited on

The reason I typed here, because I noticed few people posted Visual c++ questions. But anyways, could you please elaborate more how would I do that?

could you demonstrate with some code example please?

LB wrote:
Besides this being a C++ forum and notC#r C++/CLI forum,

If you look at the description of the this forum - it does
mention that it is for those things

The description exactly say this:

Win32, MFC, ATL, C++/CLI, .NET ...

Now I would've appreciated if you would have helped instead of keep mentioning this.

I'm sorry, I didn't notice this was in the Windows development forum.

Event handling involves setting up even handlers which you program to respond to events. An event can be anything from a mouse click to a keyboard input to the OS letting you know it is shutting down.

This is one of many resources, unfortunately information is all spread out for various languages and such.

Just look into event handling and event-driven GUIs - using while loops for your buttons is not going to work very well.
Topic archived. No new replies allowed.