Task
The .NET type representing an operation that may still be running and will eventually complete with a result, an exception or cancellation.
In more detail
Async methods return Task or Task<T>, and callers await them. A task is usually already running when you get it; awaiting it only observes it. By convention async method names end in Async.
Related terms
- async and await — Language keywords for writing code that waits for slow work, such as a network call, without blocking a thread.
- ValueTask<T> — A cheaper alternative to Task<T> that avoids an allocation when an async method usually finishes synchronously, such as a cache hit.
- Task.WhenAll — A .NET method that returns one task which completes when all the tasks you pass it have completed.
Taught in
- Async and Await: Managing Concurrency — Modern .NET Core, C# & Enterprise Microservices
- The Dependency Injection Container: Scopes and Lifetimes — Modern .NET Core, C# & Enterprise Microservices
- The Repository Pattern — Modern .NET Core, C# & Enterprise Microservices