Topic

.NET & C#

Runtime behaviour, async, memory and APIs, explained from the source and checked with code you can run.

Performance & Data14 min

Telemetry Event Formats: Units, Versions, Bytes and CPU in .NET

A strict C# telemetry codec followed byte by byte: why a tolerant JSON reader turns 1.5 ms into 1.5 s, and what Brotli, buffers and decoders really cost on .NET 10.

.NET & C#16 min

Async Work Is Not on the Thread Stack: Tracing Suspended .NET Code

Why a live stack cannot show awaiting callers, how .NET 11's async profiler records the continuation chain instead, and why request identity must come from your own trace ID.

Performance & Data11 min

SQL Date Filters: Keep the Business Day and Count the Rows Read

Compute 23-hour and 25-hour local days at both ends, filter with typed half-open intervals, and see why a CONVERT(date) seek still read twice the rows on SQL Server 2025.

AI Engineering15 min

Why an Agent Keeps Replanning: Build a Loop That Can Stop

Rephrased plans are not progress. Build a C# controller that separates new facts from new wording, refuses stale commits and ends every agent run with a typed reason.

.NET & C#14 min

Lazy<T> Under Contention: Racing Factories, Cached Failures, Blocked Threads

What each LazyThreadSafetyMode really does on the first call: losing factories that keep their side effects, exceptions cached forever, blocked callers, and an async cache that recovers.

AI Engineering15 min

Agent Spending Authority: Reservations, Approvals, Uncertain Charges

Two agent tools read the same balance and both spend. Reserve capacity atomically in C#, bind approvals to one operation, and keep units held until the destination confirms the charge.

AI Engineering16 min

The Real Cost of an AI Agent: Count the Work That Failed

A cheaper model call can still make accepted work more expensive. Build a C# cost ledger that counts failed attempts, divides by accepted tasks and keeps unknown usage unknown.

.NET & C#14 min

Why .NET 11 Removes This Box, but Keeps That Allocation

One binary on .NET 10 and .NET 11: nullable boxes that stay local stop allocating, escaping boxes and closures do not. Read the JIT code and the measurements behind each case.

.NET & C#17 min

A Timeout Is Not Cancellation: WaitAsync, WhenAny and Lost Commits

Why Task.WaitAsync and Task.WhenAny end your wait but not the work, and how an owner, a shared deadline and a stored receipt keep a timed-out reservation from happening twice.

.NET & C#14 min

Reusable ValueTask Sources: When Is It Safe to Call Reset?

Build an IValueTaskSource that survives reuse: release in GetResult, reserve completion before SetResult, and stop an inline consumer from breaking the next operation.

.NET & C#14 min

Runtime Async in .NET 11: Who Builds the State Machine Now?

In .NET 11 the JIT, not the C# compiler, can implement async methods. Read the IL and x64 it produces, and see what changes for completed and suspended calls.

.NET & C#13 min

ArrayPool Across await: Leases, Ownership Transfer and Real Savings

Reproduce the HELLO-to-WORLD overwrite with ArrayPool.Shared, end leases at the right event, transfer ownership through a bounded queue and measure what pooling really saves.