I started watching Jon Skeet's presentation on C# Async CTP. He stuttered when it came to specifying timeouts.
Coming from fairly limited exposure to F#, there is an intuitive, centralized, and simple way to specify timeouts. So, I am wondering what is the current state of affairs: can C# Async CTP do all the things that F# async block runner does? Is there a document that outlines differences and limitations?
Additional details: In F#, the async block runner provides a way to specify the following:
Here's a way to do these things in F#: Order of arguments and pipe-right operator
I don't even remember mentioning timeouts - but I'll take your word for it :)
It's fairly easy to compose tasks to achieve a timeout: create a second task which is a "delay", and then wait for either that or the original task to complete. Whichever one gets there first, cancel the other if feasible (with a cancellation token). The newly created task will complete with either the result of the main operation (if that succeeded) or an exception if the "delay" finished first.
I don't see anything like that directly supported in AsyncCtpLibrary.dll, but you can build it reasonably easily from the tools which are provided. You may want to look in the "Task-Based Asynchronous Pattern Overview" and "TPL Dataflow" documents to see if they cover it, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With