Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
17 posts found
C# Synchronization: lock, Interlocked, SemaphoreSlim and Concurrent Collections
Backend PART 13

C# Synchronization: lock, Interlocked, SemaphoreSlim and Concurrent Collections

Why sold++ never reaches a million: race conditions and the check-then-act race. The rules of lock and why you can't await inside it, atomic counters and CompareExchange with Interlocked, the SemaphoreSlim pattern for an async cache, ConcurrentDictionary factories that run more than once and the Lazy<T> fix.

7 Nov 2026 11 min 8
Producer/Consumer with C# Channels: Backpressure, Bounded Channels and Pipelines
Backend PART 14

Producer/Consumer with C# Channels: Backpressure, Bounded Channels and Pipelines

An async queue with System.Threading.Channels: why three orders fit into a channel with a capacity of two, Writer/Reader and Complete, the WaitToReadAsync/TryRead loop, FullMode options and itemDropped on bounded channels, multiple consumers, an order pipeline that passes failures on with Complete(ex), and the cost of forgetting Complete.

7 Nov 2026 9 min 8
C# Timers and Waiting: PeriodicTimer, WaitAsync and Task.Delay
Backend PART 15

C# Timers and Waiting: PeriodicTimer, WaitAsync and Task.Delay

Overlapping callbacks in System.Threading.Timer, overlap-free periodic work with .NET 6 PeriodicTimer, how Thread.Sleep and Task.Delay affect the thread pool and how precise Task.Delay is, System.Timers.Timer swallowing exceptions, WaitAsync not canceling the operation, retries with backoff and jitter, and a timer collected by the GC.

7 Nov 2026 10 min 9
C# Async and .NET 8: TimeProvider, ConfigureAwaitOptions, Parallel.ForAsync and CancelAsync
Backend PART 16

C# Async and .NET 8: TimeProvider, ConfigureAwaitOptions, Parallel.ForAsync and CancelAsync

On .NET 6 we wrote our own IClock; on .NET 8, TimeProvider and FakeTimeProvider make a 15-minute wait take 0 ms in a test. SuppressThrowing, which waits without throwing, and its Task<T> trap, ForceYielding, Parallel.ForAsync, which takes an index range directly, and CancelAsync, which runs callbacks without blocking the caller.

7 Nov 2026 10 min 9
C# Async and .NET 9–10: Task.WhenEach, the Lock Type and Async LINQ in the Framework
Backend PART 17

C# Async and .NET 9–10: Task.WhenEach, the Lock Type and Async LINQ in the Framework

The .NET 9 Task.WhenEach that replaces the WhenAny loop and how it handles failed tasks, System.Threading.Lock recognized by the C# 13 lock statement and its limits (CS9216, CS1996, CS4007, CS9202), async LINQ moving into the framework in .NET 10, async Select, and fixing the clash with the System.Linq.Async package.

7 Nov 2026 11 min 7
Blog Map