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
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