• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Simplify the creation of events and their call


New member
Apr 18, 2019
Programming Experience
When you creating events, it takes a lot of time to writing service code.
You need:
class EventArgs - for data
class TODO - which doing some manipulation of data (it contains delegate, event and TODOMethod -for event calling)
MethodHandler(object sender, EventArgs e), which subscribed on event and will been called when if statment == true e.c.
It could be simplified, like async/await. This is must be some simple expression like
MethodHandler(some type of data) => when counter = 100;
And it statement will create all service code: EventArgs, TODO, MethodHandler()


C# Forum Moderator
Staff member
Apr 23, 2011
Sydney, Australia
Programming Experience
I think that you're asking a question but I'm not sure. Firstly, you don't need to define your own delegate. You either use the EventHandler delegate if your event requires no data or the EventHandler<TEventArgs> if your event does require data.
public event EventHandler EventWithoutData;
public event EventHandler<EventArgs> EventWithData;
You should use an existing class that inherits EventArgs if you can but, if you need a custom class, you really have no choice but to create that class yourself. A separate class couldn't be generated by a snippet in the class that the event is a member of and you'd still have to add the properties yourself anyway. You could write a code snippet that generated the event declaration and the definition of the method that raises that event.
Top Bottom