What problem does it solve?
Async methods can become brittle when naming, awaiting, and cancellation patterns diverge, leading to deadlocks, swallowed exceptions, or blocked thread pools. This guidance ensures Task-based code stays non-blocking, configurable, and cancellation-aware across libraries and APIs.
Core Features & Use Cases
- Naming and Return Values: Append Async to asynchronous method names and return Task or Task<T> to clearly signal their behavior.
- Awaiting Practices: Never block on asynchronous work and apply ConfigureAwait(false) in library code while leveraging Task.WhenAll/WhenAny for parallel or timeout handling.
- Cancellation and Ownership: Pass CancellationToken through long-running flows, especially for HTTP, database, and background work, and avoid unmanaged background tasks without clear ownership.
- Use Case Example: Refactor a data-fetching service to embrace these rules so HTTP clients, timers, and database calls remain cancellable and exception-safe.
Quick Start
Apply the rm-guide-async checklist to this new API method to ensure it returns Task, avoids blocking calls, and propagates its cancellation tokens.