Browse by Topic

Popular

Latest

Latest C# Posts

Technical illustration of an async lambda expression in C# showing a task returning from a lambda with await inside.
C#

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#async/awaitlambda expressionsTask
Illustration comparing Task and ValueTask in C#, showing a heap allocation versus a stack-based struct.
C#

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#asyncValueTaskTask
Diagram showing a ValueTask struct returning a value directly versus wrapping a Task, with an arrow indicating reduced allocation.
C#

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.

ValueTaskasync/awaitperformanceC#
Illustration of a C# async method with ConfigureAwait controlling whether the continuation returns to the UI thread or runs on the thread pool.
C#

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.

async-awaitSynchronizationContextdeadlock.NET
Diagram showing a C# Task.Delay timer completing asynchronously without blocking the calling thread.
C#

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.

Task.Delayasync-awaitcancellationtimers
Illustration of multiple asynchronous tasks racing, with the first completed one highlighted as Task.WhenAny in C#.
C#

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.

C#asyncconcurrencyTask.WhenAny
Illustration of multiple asynchronous tasks merging into a single await point in C#
C#

C# Task.WhenAll: Awaiting Multiple Tasks

Use C# Task.WhenAll to await multiple independent asynchronous operations, collect their results, observe exceptions, and control concurrency.

C#asyncTask.WhenAllconcurrency
Comparison of await and Task.Result in C# showing a deadlock risk
C#

C# await vs Task.Result: Avoid Blocking Async Code

c# await vs task result: Understand the difference between await and Task.Result in C#, why blocking on async tasks can cause deadlocks, and when it's acceptable.

async/awaitTaskdeadlockthread pool
Illustration of a C# Task returning a value, showing the flow from an async operation to the awaited result.
C#

C# Task Result: How to Access Values from Async Methods

Learn how to access a C# Task<T> result with await, .Result, and GetAwaiter().GetResult(), including exception handling and deadlock avoidance.

async/awaitTask<T>concurrency.NET
Diagram contrasting async void and async Task in C#, showing exception flow and awaitability
C#

C# async void vs Task: Key Differences

C# async void vs Task: learn how their exception behavior and awaitability differ, when async void is required, and why async Task is the safer default.

asyncC#Taskexception handling