Can I have all the options like OnlyOnRanToCompletion, OnlyOnCanceled, NotOnFaulted, etc. using async/await?
You don't need to.
Instead of copious syntax using bit flags and lambda continuations, await
supports a very natural try
/catch
syntax:
try
{
await foo();
}
catch
{
bar();
throw;
}
I'm not sure if simple conditional or exception handling can manage all the continuation behaviors available in explicit Tasks.
They naturally handle None
, NotOnCanceled
, NotOnFaulted
, NotOnRanToCompletion
, OnlyOnCanceled
, OnlyOnFaulted
, and OnlyOnRanToCompletion
. Most of the other flags only make sense for parallel tasks, not asynchronous tasks. E.g., AttachedToParent
, HideScheduler
, and PreferFairness
don't make sense in the async
world; DenyChildAttach
, LazyCancellation
, and ExecuteSynchronously
should always be specified in the async
world; and LongRunning
never should be.