Skip to content

Latest commit

 

History

History

README.md

Event Handler Example - C# Event Handler Patterns with Custom EventArgs and Observer Pattern

YouTube Blog Newsletter All Links LinkedIn

This Windows Forms application demonstrates the event handler and observer pattern in C# using .NET Framework 2.0. It implements a text capitalization processor that uses custom events to delegate decisions about non-alphabetic characters to event subscribers. The project showcases the publisher-subscriber pattern with loose coupling, where the Processor class raises a CheckProcess event for each non-standard character, and the UI subscribes to handle these events interactively via message box prompts.

The solution is structured with four projects following a layered architecture: a WinForms executable entry point, an application layer containing the event-driven business logic with IProcessor interface and Processor implementation, a data layer, and a presentation layer with the MainForm. Key patterns demonstrated include custom EventArgs with two-way communication through the Skip property, null-safe event invocation, and lambda-based event subscription. This is a practical example of how C# events enable decoupled component communication.

Getting Started

Prerequisites

  • .NET Framework 2.0 or later
  • Visual Studio (for WinForms designer support)

Running the Project

Open the solution in Visual Studio and run the Example project.

Newsletter

If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:

Subscribe to Dev Leader Weekly

Connect with Dev Leader


BrandGhost

Powered by BrandGhost 👻