Home › .NET Framework (Legacy & Enterprise)
.NET Framework 4.5+ has async/await and the TPL. Need Use I/O-bound work (DB, HTTP, files) async/await with Async APIs CPU-bound work in parallel Parallel.ForEach, PLINQ AsParallel(), Task.Run Several independent operations await Task.WhenAll(...) Timeout / cancellation CancellationTokenSource(TimeSpan) Producer/consumer BlockingCollection<T>, TPL Dataflow Thread-safe collections ConcurrentDictionary, ConcurrentQueue Classic ASP.NET pitfalls Never block on async code (.Result, .Wait()) in ASP.NET (pre-Core) or UI apps — it deadlocks on the synchronization context. In library code use ConfigureAwait(false). Don't use Task.Run to fake async in ASP.NET — it just moves work to another thread-pool thread. async void only for event handlers.