June 30th, 2013, 09:07 AM
Question about running a program in a loop
Say that you have a simple program with a start and a stop button. Once the start button is start, the program should loop through some code at every new second. Then how can you make the stop button break the loop that is activated with the start button?
I figured something like this:
bool keepRunning = true;
private void StartButton(object sender, EventArgs e)
NewSecond = DateTime.Now.Second;
MemSecond = NewSecond;
//run the program that's in the loop
private void StopButton(object sender, EventArgs e)
keepRunning = false;
But then I get an not responding program?
July 1st, 2013, 03:46 AM
Re: Question about running a program in a loop
I am not sure , but I think you will need to use a thread.
Click Here to Expand Forum to Full Width