Quantcast
Channel: Asynchronously wait for Task to complete with timeout - Stack Overflow
Viewing all articles
Browse latest Browse all 20

Asynchronously wait for Task to complete with timeout

$
0
0

I want to wait for a Task<T> to complete with some special rules:If it hasn't completed after X milliseconds, I want to display a message to the user.And if it hasn't completed after Y milliseconds, I want to automatically request cancellation.

I can use Task.ContinueWith to asynchronously wait for the task to complete (i.e. schedule an action to be executed when the task is complete), but that doesn't allow to specify a timeout.I can use Task.Wait to synchronously wait for the task to complete with a timeout, but that blocks my thread.How can I asynchronously wait for the task to complete with a timeout?


Viewing all articles
Browse latest Browse all 20

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>