Notifying the Firing Class
Next, let’s add a notification to the instance of the class module so that the code placed in the event
handler is processed when the event is fired. As a preliminary to doing this, we’ll need to create an
instance of Class1 in the form class. I’m going to create a Button named btnDoPrimeThing, with the
intention of placing the code to be executed in the Button’s click event, and displaying the rests in a
multi-line Textbox.
Here’s the code in the click event that creates an instance of Class1 and tells the event in the class
to notify the event handler in the form class when it is fired:
private void btnDoPrimeThing_Click(object sender, System.EventArgs e) {
Class1 class1 = new Class1();
class1.OnPrime += new Class1.OnPrimeEventHandler
(this.Class1_OnPrime);
}
|
|
Search Engine Optimization
 
Syndication Viewer
Our Web host:
IX WebHosting
|