Skip to content

Async and UI Thread

David Ortinau edited this page Apr 10, 2025 · 4 revisions

Validate Async Code and UI Thread Usage

Misuse of async/await is one of the most common causes of UI hangs in .NET MAUI apps.

🔍 What to Look For

  • Use of .Result, .Wait(), or .GetAwaiter().GetResult()
  • async void methods not attached to UI events
  • Long-running synchronous methods or loops triggered from the UI thread

✅ Fix Examples

❌ Bad:

var result = service.GetDataAsync().Result; // blocks UI thread

✅ Good:

var result = await service.GetDataAsync();

🛠 Suggested Review Steps

  1. Search your project for blocking calls: .Result, .Wait(
  2. Convert them to await patterns wherever possible
  3. Identify heavy work running on the UI thread and move to Task.Run

➡️ [Next: Audit Layout Complexity](./layout-performance.md)


Clone this wiki locally