I am a rather inexperienced C # programmer and need help managing the flow of my program. This is WinFormApp, which requests several user inputs and then uses them to establish serial communication with the device for taking measurements. Measurements are made in an asynchronous method, which takes about 20 minutes. Therefore i use
void main()
{
}
private void button1_Click(object sender, EventArgs e)
{
await measurements();
}
private async Task measurements()
{
while(true){
await Task.Delay(120000);
}
}
Now I need to make a button that allows the user to cancel the measurement, to change any input or parameter, and then restart the measurement. So I added a Cancel button.
private void button7_Click(object sender, EventArgs e)
{
textBox64.Enabled = true;
button6.Enabled = true;
button5.Enabled = true;
textBox63.Enabled = true;
button3.Enabled = true;
trackBar1.Enabled = true;
timer.Enabled = true;
button7.Enabled = false;
clearData();
}
, . try-catch button1_Click() button7_Click, button1_Click().
measurements() . 70- UI .
, .
, , , , Goto.