1
I have this method async
currently waiting for a time declared by me. The program first restarts the boolean
result and then send commands to a serial that after a certain time returns in my program the results in that same boolean
.
But it’s obviously bad practice I need to set the time "hard coded
" why for some reason can get the answer faster than expected, or even slower. Below a sample of how is the code:
public async Task StartNewTest(TestType test)
{
double time = 0;
switch(test)
{
case TestType.Alerts:
time = 20000;
AlertOK = false;
SendSerial("A");
case TestType.Lights:
time = 18000;
LightsOK = false;
SendSerial("L");
}
await Task.Delay(TimeSpan.FromMilliseconds(time));
}
So it’s functional. But I’d like to stop using this form this time, waiting for Boolean AlertOK
stick around true
for example.
Like it was (just an idea).
await AlertOK == true