The code below defines an event (GooEvent), a class that raises the event (SampleGooEventSource) and a class that handles the event (SampleGooListener). Data is passed to the event handler in members of the GooEvent object that is passed to the Goo method defined in the GooListener interface. Handlers can be registered by passing them to the SampleGooEventSource’s AddGooListener method. When the event source raises the event, the Goo method of all listeners will be called.
Notice that this code is not best practice for .NET programming, it simply imitates the pattern used in Java for event handling for demonstration purposes: