gui in c#

i want to press button2 and then that var will be changed the problem is during the run the button 2 seems locked i want to press several time button2 and see thing changing should i define somthing about button2 or for the gui

Comments

: hi i have gui with two buttons: : button1 button2: : when i press button1 the programs starts loop: : for (;): dosomthing(var): : i want to press button2 and then that var will be changed the problem is during the run the button 2 seems locked i want to press several time button2 and see thing changing : should i define somthing about button2 or for the gui: : thanks:

As long as a loop is looping, the program will not respond, because the eventmessage loop(the code which handles MouseClick etc.; automatic generated) can't continue looping. You have to give your program time to react on events.

I always use a Timer based loop:- declare the variables used in the "for"-loop as privates of the Form.- put the "dosomthing"-code in the Timer_Tick

If the "dosomthing"-code needs no much time and you have to run the loop fast, you can also put the "dosomthing"-code between a "timestoper"-loop: