This post follows from our previous post called C# Events Example Part 2. In this post we will make another change to our code.
In our example we are processing Items. These could be anything. Perhaps we are processing text files or some type of media file. Perhaps the item is a Customer.
What if we wanted each of the subscribers to know something about the Item that we are processing? How do we do that? First, have a look at the code for the ItemProcessor.cs file. We will change EventArgs. We can create another class that inherits from EventArgs and adds a property. Here below is the code we have now.
Next we change a little bit of code in our two subscribers. Below is the code from our changed SubscriberOne.cs file. Instead of EventArgs we now use ItemEventArgs and args instead of e. We also have the ability to get the name of the item, as you can see in the Console.WriteLine() line of code.