All syntax guides
Short, practical guides on programming syntax, language fundamentals, and the tools developers reach for every day.
3,980 guides across 14 topics
Topics
Popular guides
Most readLatest guides
Page 329 of 398C# Task Cancellation: Using CancellationToken Correctly
Learn how to implement cooperative cancellation in C# tasks with CancellationTokenSource and CancellationToken, handle OperationCanceledException, and avoid common pitfalls.
C# CancellationToken: How to Cancel Operations Gracefully
Understand how to use C# CancellationToken to cancel async and sync operations gracefully, handle OperationCanceledException, and combine tokens with timeouts.
Handling Exceptions in C# Async Methods with try/catch
Learn how to use try/catch with async methods in C#: exception propagation, async void risks, exception filters, and practical retry and cleanup patterns.
C# Async Exception Handling: Patterns That Work
Learn how exceptions propagate in C# async methods and how to catch them reliably with await, Task.WhenAll, async void, and cancellation scenarios.
C# async lambda: Syntax, Behavior, and Pitfalls
C# async lambda syntax lets you use await inside a delegate. This guide explains where async lambdas are allowed and how to avoid common runtime pitfalls with exceptions, LINQ, and concurrency.
C# Task vs ValueTask: Choosing the Right Async Return Type
Understanding the differences between Task and ValueTask in C#, when each return type is appropriate, and how ValueTask can reduce allocations in performance-sensitive code.
C# ValueTask: When and How to Use It
C# ValueTask can reduce async allocations in hot paths, but it is not a drop-in replacement for Task. Learn when to use it, when to avoid it, and how to avoid common pitfalls.
C# ConfigureAwait: When and Why to Use It
Understand what C# ConfigureAwait does, when to use ConfigureAwait(false) in async libraries, and why UI code should keep the default await behavior to avoid context-capture pitfalls.
C# Task.Delay: Async Timing Without Blocking Threads
Practical C# Task.Delay guide covering async usage, cancellation, overload selection, runtime behavior, and common mistakes to avoid.
C# Task.WhenAny: Handling the First Completed Task
Learn how to use C# Task.WhenAny to await the first completed task, handle timeouts, filter for the first successful result, and manage cancellation.