377 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.
Threads, tasks, synchronisation primitives, advanced async patterns and the concurrency problems seen in production .NET systems.
System.Threading.Thread: what it maps to, its cost, its API surface in .NET 10 and the narrow cases where a dedicated thread is the right choice.
ThreadState values, legal transitions, Join, Sleep, Interrupt and how a thread ends, including unhandled exceptions.
IsBackground, which threads are background by default, process exit rules and graceful shutdown in hosted apps.
Global and local queues, work stealing, minimum threads, hill climbing, starvation injection and the metrics to watch in .NET 10.
Worker versus completion-port threads, IOCP on Windows, epoll on Linux, how async I/O completes without a thread waiting, and what GetAvailableThreads really reports.
Per-thread state with ThreadStatic and ThreadLocal, why it breaks across await, and how AsyncLocal flows with ExecutionContext.
Task as a promise of completion, delegate tasks versus promise tasks, TaskStatus, and the core combinators in .NET 10.
`Task<T>` results, await versus .Result versus GetAwaiter().GetResult(), TaskCompletionSource of T, cached completed tasks and why `Task<T>` is not covariant.
ValueTask and `ValueTask<T>`: allocation-free synchronous completion, IValueTaskSource pooling, consumption rules and when Task is still the better choice.
The async modifier, the awaitable pattern, the IsCompleted fast path, continuation registration, context capture and valid async return types.
IAsyncStateMachine, MoveNext, the state field, hoisted locals, the method builder, boxing on first suspension and the cost model of async in .NET 10.
TaskScheduler responsibilities, the default ThreadPool scheduler, Current versus Default pitfalls with StartNew and ContinueWith, FromCurrentSynchronizationContext and ConcurrentExclusiveSchedulerPair.
ContinueWith, TaskContinuationOptions, synchronous versus asynchronous continuations, RunContinuationsAsynchronously, Unwrap and why await is usually better.
Exceptions stored in tasks, AggregateException versus await, WhenAll with several failures, cancellation status, UnobservedTaskException and async void crashes.
Lost exceptions, disposed scoped services, lost work on shutdown, no backpressure; safe alternatives with BackgroundService, Channel of T and durable queues.
lock lowering to Monitor or Lock.EnterScope, choosing the lock object, re-entrancy, why you cannot await inside a lock, and lock scope design.
Monitor.Enter/Exit, TryEnter with timeouts, Wait/Pulse/PulseAll condition signalling, thread affinity and the object header thin lock and sync block.
Kernel mutex, cross-process named mutexes, Global and Local prefixes, AbandonedMutexException, thread affinity, cost and single-instance apps.
Counting semaphores, System.Threading.Semaphore as a kernel object, named semaphores and platform limits, no thread affinity, SemaphoreFullException and use cases.
SemaphoreSlim internals, WaitAsync with timeouts and cancellation, async mutual exclusion, throttling HTTP calls, non-reentrancy and release discipline.