A library to make async even easier!
A tuple of tasks can be awaited and returns a tuple of results:
var t1 = CountAsync();
var t2 = GetMessageAsync();
// You can await tuples directly!
var (count, message) = await (t1, t2);
A tuple of tasks can be awaited and returns a tuple of results:
var tasks = new List<Task>();
foreach (var item in items)
{
var task = DoAsync(item);
tasks.Add(task);
}
// You can await enumerables directly!
var results = await tasks;
If you don't want to await on an async method, you can forget about it!
DoAsync().Forget();
instead of
_ = DoAsync();
Using Forget()
is better because you can still have exception handling by passing onException
to Forget
:
StartAsync().Forget(onException: (exception) =>
{
// Handle the exception here...
});