Creating Custom Events
This article is part of a multi-article series, C# for Newbies, intended to ease the learning curve
and help newcomers get started working productively with C#. It is the second part of a discussion
of events. The first part of this Events article discussed events generally in C#, showed how to use
the Events tab of the Properties window, and explained the auto-generated code that using the Events
tab creates.
The continuation of the Events discussion covers creating custom events. Specifically, how are they
fired, and how does your code respond to them.
I find that it’s easiest to understand a process as complex as adding a custom event in the context
of an example. The example I’ll use will be an event that is fired if a long integer passed to a
method is a prime number. The method will be placed in a class module—although since in .NET a
form is just an instance of a class it could also reside in the form class—and the form developed
in the first part of this article will both invoke the method that fires the event and respond when
the event is fired.
Here are the steps we will need to take to make this work:
Let’s take these steps from the top!
|
|
Search Engine Optimization
 
Syndication Viewer
Our Web host:
IX WebHosting
|