-
Notifications
You must be signed in to change notification settings - Fork 7
Async and UI Thread
David Ortinau edited this page Apr 10, 2025
·
4 revisions
Misuse of async/await is one of the most common causes of UI hangs in .NET MAUI apps.
- Use of
.Result,.Wait(), or.GetAwaiter().GetResult() -
async voidmethods not attached to UI events - Long-running synchronous methods or loops triggered from the UI thread
❌ Bad:
var result = service.GetDataAsync().Result; // blocks UI thread✅ Good:
var result = await service.GetDataAsync();- Search your project for blocking calls:
.Result,.Wait( - Convert them to
awaitpatterns wherever possible - Identify heavy work running on the UI thread and move to
Task.Run
➡️ [Next: Audit Layout Complexity](./layout-performance.md)