Reading the official guidelines on publishing events in .NET it says:
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.
The documentation also mentions that The .NET Framework 2.0 introduces a generic version of this delegate, EventHandler.
It then goes on to show an example using EventHandler
, but also an example using a custom delegate type.
Given that it looks like the custom delegate pattern is not strongly discouraged (it even has an official example), is it ever beneficial to create our custom delegates instead of subclassing EventArgs
and using EventHandler<CustomEventArgs>
?