2 carlzj Carlzj2016.01.31 02:33 questions

C# click the first button to click a button to stop the cycle, second cycles

C#. I set two button, click the first button of a cycle, click the second button to stop the cycle, but regardless of how to deal with the first button press are a dead loop, the program presents the locked state, how to solve the?

The 3 answer

Caozhy
Caozhy   Ds   Rxr 2016.01.31 06:28
Has adopted

When you add the cycle
(Application.DoEvents);

Caozhy
Caozhy Reply to 91program: if I remind the way what is right, or you to me what advice that you can communicate with me. With you to answer some of the answer is not water "and you go", you can see, any irrigation, I remind, not for you alone. I hope CSDN, hope everyone is good. In reality, we do not know, say you are grandparents programmer, want weight.
About a month ago reply
Caozhy
Caozhy 91program: I just want you to improve. The quality of reply. No other meaning.
About a month ago reply
91program
91program A narrow-minded guy, it did not see you to comment on my answer. You said in your grandpa, grandpa to go with you every day. What do you want!? Apologize in CSDN's Q & a group, and then come here to continue when the villain. What do you think? Caozhy said you like it.
About a month ago reply
U013538542
U013538542   2016.01.31 13:05

A button at the start of an infinite loop, will the death card interface, because this cycle is executed on the main thread,

Do you require LZ functions need to use multiple threads, the first button to start a thread, the thread executes for cycle

Second, a button to stop the thread that stop the cycle

Duwucanglan
Duwucanglan   2016.01.31 07:01

With multi thread ah, button1 boot loop thread, button2 stop

Csdn user default icon
Upload...
Upload photo
Insert a picture