Asynchronously wait for Task to complete with timeout
How about this: int timeout = 1000; var task = SomeOperationAsync(); if (await Task.WhenAny(task, Task.Delay(timeout)) == task) { // task completed within timeout } else { // timeout logic } And here’s a great blog post “Crafting a Task.TimeoutAfter Method” (from MS Parallel Library team) with more info on this sort of thing. Addition: at … Read more