Need some help with an event. Im in the process of writing a program that sends data to a usb port for a motor controler. Im stuck in a situation where I want to pause the program using a button from within a for loop, evewrything I do I end up with this. Error 1 Operator '!' cannot be applied to operand of type 'System.Windows.Forms.Button'
here is the code sample I have.
for (int stpnt = DataArray[1]; stpnt > DataArray[0]; stpnt--){
lblAddress.Text =
Convert.ToString(stpnt);lblSndDta.Text =
Convert.ToString(DataArray[3]);pgbProgress.Value = 0;
btnPause.Text =
"Pause"; for (int x = 0; x < DataArray[2]; x++){
while (!btnPause){
// Insert the pause program button herepgbProgress.Value = x;
this.Refresh();}
btnPause.Text =
"Unpause";}
}
is there a way "besides creating a new event" that I can use the button within a for loop
electroteck
Ryan AlfordPosted Jul 24, 2008, 11:51 AM
What is the negative/opposite of a button? That is basically what you are going for with "!btnPause".
you will probably need to look into using threading. You will not be able to do the For loop processing on the same thread as the UI is being displayed. You will need separate threads.