I have a program that will read some values from 2 readers located at different physical locations. For one reader I know I can write like:
private async void waitForReading() { string result = await readFromReader1(); return result; } private async Task<string> readFromReader1() { //poll until value detected return reader1Value; } private async Task<string> readFromReader2() { //poll until value detected return reader2Value; } However, what if I read from two readers and resume execution when one of the task returned?
What I want to achieve looks like:
private async void waitForReading() { string result = await readFromReader1() || readFromReader2(); return result; } Is it possible?