This document contains the agenda and slides for a talk titled "Xamarin Talks #1" given by Paulo Morgado. The talk discusses best practices for asynchronous programming using async and await in C#, including only using async void for event handlers, determining whether a task is CPU-bound or I/O-bound, using Task.Run appropriately, avoiding deadlocks, using ConfigureAwait(false), and caching returned tasks. The slides provide code examples and explanations to illustrate the concepts.
11. Two ways of thinking about asynchrony
Foo(); var task = FooAsync();
From the method signature (how people call it)
void Foo()
{
for (int i=0; i<100; i++)
Math.Sin(i);
}
From the method implementation (what resources it uses)
async Task FooAsync()
{
await client.DownloadAsync();
}
12. Async methods: Your caller’s assumptions
Is this true for your async methods?