private void ButtonStartInfiniteLoop_Click(object sender, EventArgs e) { MakeInformationLabelsInvisible(); ButtonCancelInfiniteLoop.Enabled = true; TurnOffStartButtons(); TextBoxNumberSeconds.Enabled = false; // idem ProgressBar.Value = 0; if (TextBoxNumberSeconds.Text.Trim() != "") { LabelErrorMsg.Visible = true; LabelErrorMsg.Text = "Aantal seconden moet leeg zijn"; SetInitialButtons(); TextBoxNumberSeconds.Enabled = true; // idem return; } if (backgroundWorker.IsBusy == true) { LabelErrorMsg.Visible = true; LabelErrorMsg.Text = "Achtergrond proces loopt nog"; return; } var backGroundParams = new BackGroundParamsInc { NrOfSeconds = 0, KindOfLoop = KindOfLoop.Infinite }; backgroundWorker.RunWorkerAsync(backGroundParams); }
private void ButtonStart1Loop_Click(object sender, EventArgs e) { MakeInformationLabelsInvisible(); ButtonCancelInfiniteLoop.Enabled = false; // Je kan alleen cancellen bij infinite loop TurnOffStartButtons(); ProgressBar.Value = 0; var ok = int.TryParse(TextBoxNumberSeconds.Text, out int nrOfSeconds); if (!ok || nrOfSeconds < 5) { LabelErrorMsg.Visible = true; LabelErrorMsg.Text = "Aantal seconden moet 5 of meer zijn"; SetInitialButtons(); return; } if (backgroundWorker.IsBusy == true) { LabelErrorMsg.Visible = true; LabelErrorMsg.Text = "Achtergrond proces loopt nog"; return; } // Onze zelfgemaakte object backGroundParams geven we mee aan RunWorkerAsync // RunWorkerAsync zit onder water (geen code beschikbaar), deze roept weer // BackGroundWorker_DoWork aan. var backGroundParams = new BackGroundParamsInc { NrOfSeconds = nrOfSeconds, KindOfLoop = KindOfLoop.Once }; if (backgroundWorker.IsBusy == false) { backgroundWorker.RunWorkerAsync(backGroundParams); } }