by Jonathan Bright | Nov 5, 2026 | Tutorials
A compression round trip has one decisive check: do the decompressed bytes equal the original bytes? This console program uses BrotliStream to answer that question for repeated text, seeded random bytes and an empty array. It also prints a size table for three...
by Jonathan Bright | Nov 5, 2026 | Tutorials
Keep a lock’s identity under your control. A string, a publicly accessible object, or a Type can let unrelated code acquire the same gate and delay your operation. A dedicated private gate prevents callers from obtaining that gate through your public API. This...
by Jonathan Bright | Nov 5, 2026 | Tutorials
Use lock for a short synchronous critical section. Use Monitor directly when synchronous acquisition needs an explicit timeout. Use a one-permit SemaphoreSlim when the protected operation must continue across await. The key difference is who owns the gate and how...
by Jonathan Bright | Nov 5, 2026 | Tutorials
A ConcurrentDictionary can safely store values while several workers use it, yet a counter built from a separate read and write can still lose increments. This tutorial forces that failure, replaces the counter operation with AddOrUpdate, and demonstrates why its...
by Jonathan Bright | Nov 4, 2026 | Tutorials
A quiz can keep the same validation and acceptance rule while changing how it awards points. The useful boundary is between the evaluator and the scoring formula: the evaluator asks an interface for points, and the startup code supplies the implementation. This...
by Jonathan Bright | Nov 4, 2026 | Tutorials
A turn-based battle needs a rule for deciding who acts next. Here, a Knight and a Goblin both start at tick zero. The Knight acts first because it was scheduled first; after that, each fighter waits its own delay before attacking again. We will use a priority queue to...