Fast, fluid, instant-gratification apps are a must for mobile and C# async makes this much easier to accomplish.
Slides are from the Xamarin CTO and cofounder Miguel de Icaza to understand how and why you should use async for your mobile apps.
Ensuring Technical Readiness For Copilot in Microsoft 365
C# Async on iOS and Android - Miguel de Icaza, CTO of Xamarin
1. C# Async on iOS and Android
Miguel de Icaza, CTO
@migueldeicaza
2. C# 5.0 Async on iOS and Android
• Just released our C# 5 compiler
– Async programming
• Support both .NET Base Class Libraries Async
• Async-ready APIs for iOS and Android
8. C# and Lambdas
• They add a whole level of sanity
• Shared state across lambdas
– Compiler does the heavy lifting
• Requires all lambdas to share a scope
20. Problems with callbacks
• Control flow is difficult
– Achieved by choosing what to call next
– Tracking state across callbacks
• Updating code is cumbersome
– Error prone
• Error reporting is bolted on the basic framework
– Poor, and recovery is typically obnoxious, or non-existent
21. Go To Statement Considered Harmful
“our intellectual powers are rather geared to master static
relations and that our powers to visualize processes evolving
in time are relatively poorly developed.
For that reason we should do our utmost to shorten the
conceptual gap between the static program and the dynamic
process, to make the correspondence between the program
(spread out in text space) and the process (spread out in time)
as trivial as possible.” – Edsger W Dijkstra
22. How did we cope with GoTo?
• New idioms
– Structured Programming
• Better languages
– We had the compiler do the work for us
25. Evolution: Tasks
• Reasoning about background operations
– Task and Task<T> types
• They encapsulate a unit of work, and have:
– State: running, finished, cancelled
– Result
– Exceptions thrown (if any)
30. Async Support
• Base Class Libraries:
– Expect all the standard Async APIs from .NET BCL
– Coverage is .NET 4.5 Complete for BCL
• More Async Sources:
– Xamarin.iOS: 174
– Xamarin.Android: 337
– Xamarin.Mobile
– Xamarin Component Store
31. What is available as Async?
• Simple Rule:
– Any API that would take more than 50ms to run