event and delegate

T

Tony Johansson

Hello!

I have a snippet from a class called TemperatureMonitor below.
Now to my question as you can see I fire the machineOverheating event which
is of
type StopMachineDelegate in the Notify method.

Question 1: Would it be possible to fire the event machineOverheating from
another class insted and if yes
what requirement must this new class fulfil?
For example must this new class that will fire the machineOverheating event
perhaps be derived from this
TemperatureMonitor class.

I compare a little bit with the .NET framework class control and the class
button. Class control is the base class for class Button.
I assume that the event field declaration is done in the control class but
you can fire the event from a class that is different from the class where
you declared the event. So you fire the event from the Button class but the
event fiead declaration is done in the Control class.


class TemperatureMonitor
{
public delegate void StopMachineDelegate;
public event StopMachineDelegate machineOverheating;
....

private void Notify()
{
if ( machineOverheating != null)
{
machineOverheating ();
}
}
}

//Tony
 
P

Peter Duniho

Question 1: Would it be possible to fire the event machineOverheating
from
another class insted and if yes
what requirement must this new class fulfil?

How is this question different from the last time you asked it, and why
were the previous replies insufficient?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top