logo search
CSharp_Prog_Guide

Отмена подписки на событие

How to: Publish Events that Conform to .NET Framework Guidelines

The following procedure demonstrates how to add events that follow the standard .NET Framework pattern to your own classes and structs. All events in the .NET Framework class library are based on the EventHandler delegate, which is defined as follows:

public delegate void EventHandler(object sender, EventArgs e);

Note:

The .NET Framework 2.0 introduces a generic version of this delegate, EventHandler<(Of <(TEventArgs>)>). The following examples show how to use both versions.

Although events in classes that you define can be based on any valid delegate type, even delegates that return a value, it is generally recommended that you base your events on the .NET Framework pattern by using EventHandler, as shown in the following example.