I have one async task running an infinite loop doing some realtime processing:
private async void RealTimeProcessingAsync()
{
while (true)
{
//....
Tmstaus status = await ReadStatusAsync();
switch (status)
{
case Ack:
//...
break;
//...
}
//...
}
}
And I created another async method SendWriteRqst that post command to RealTimeProcessingAsync(), should wait for status to set to defined condition and return.
public async Task<WriteState> SendWriteRqstAsync(TmCommand tmCmd)
{
//...
await SomeCondition()//based on status value
//...
return wrState;
}
It will works if SomeCondition() runs another while loop to polling status and return true if conditions set, but I'm looking for better solution.
(Sorry for bad English)