Introduction Event-Driven Programming
Introduction Event-Driven Programming
JOSEPH U.ESPERANZA
Outline
I. What is an event driven system?
notifies
Event Source Event Handler
modifies
System Objects
What makes this model unique?
1. Loose Coupling between source and
handler
– Runtime registration
– Multicasting
– Multiplexing
– Separate Compilation
– Inverted Semantics
Runtime registration
document.getElementById("myButton").addEventListener("click", function() {
alert("Button was clicked!");
});
In this example, the addEventListener method registers a click event handler for a
button with the ID myButton during the program’s execution.
Multicasting
public delegate void Notify(); // Delegate In this example,
public class ProcessBusinessLogic
the ProcessCompleted event is multicast to
{ two
public event Notify ProcessCompleted; // Event
handlers: bl_ProcessCompleted1 and bl_Proces
public void StartProcess() sCompleted2.
{
// Some process logic here
OnProcessCompleted();
}
bl.StartProcess();
}