I have this async
method that currently expects a time declared by me. The program first restarts the boolean
of result and then sends commands to a serial that after a certain time returns in my program the results in that same boolean
.
But it's obviously a bad practice to have to set the time " hard coded
" because for some reason the response may be faster than expected, or slower. Here is a sample of what the code looks like:
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));
}
In this way, it is functional. But I would like to stop using this form, this time, expecting the% boolean AlertOK
to be true
for example.
As if it were (just an idea).
await AlertOK == true