In this lecture we'll look at real-world scenarios for using events in .NET: reacting to user actions, progress and completion notifications, lifecycle events of domain objects, working in multithreaded environments (marshaling via
SynchronizationContext/
Dispatcher) and the
Event Aggregator pattern. We'll discuss best practices: standard delegates
EventHandler/
EventHandler<T>, immutable
EventArgs, safe invocation via
?.Invoke, encapsulation via
OnEventName, unsubscribing to prevent leaks, and thread-safety.