Start/stop button
-
I am wanting to use a button on a form as a start/stop button for a piece of code. I could put the piece of code in the click function for the button, but is there a better way of achieving this? Via a object of another function? If so how would I trigger the start stop? Please give a code example. Thanks in advance.
-
I am wanting to use a button on a form as a start/stop button for a piece of code. I could put the piece of code in the click function for the button, but is there a better way of achieving this? Via a object of another function? If so how would I trigger the start stop? Please give a code example. Thanks in advance.
Well, my idea would be to use a variable: bool a; ... in the mouse_click event you write: if(a == true) {function_call(var1);} else {function_call(var2);} i did not quite get it what you were doing, but... if that is what you were doing, sorry. in another way i don't know.
-
I am wanting to use a button on a form as a start/stop button for a piece of code. I could put the piece of code in the click function for the button, but is there a better way of achieving this? Via a object of another function? If so how would I trigger the start stop? Please give a code example. Thanks in advance.
You may use a thread and in the start method of the thread you put your code and when clicking on the strat button you start the thread and you stop it when clicking on the stop button. if you can provide us some code of yours we may help more. good luck
-
Well, my idea would be to use a variable: bool a; ... in the mouse_click event you write: if(a == true) {function_call(var1);} else {function_call(var2);} i did not quite get it what you were doing, but... if that is what you were doing, sorry. in another way i don't know.
-
I am wanting to use a button on a form as a start/stop button for a piece of code. I could put the piece of code in the click function for the button, but is there a better way of achieving this? Via a object of another function? If so how would I trigger the start stop? Please give a code example. Thanks in advance.
Use a
BackgroundWorker
and set it to accept cancellation.SkyWalker
-
Use a
BackgroundWorker
and set it to accept cancellation.SkyWalker
-
Super :-)
SkyWalker