EventHandlers In Ax 2009

It is possible to attach event listeners to objects in X++.
The next code sample shows the usage of the SysEventBroker and SysEventInfo classes to handle events :

static void SysEventTest(Args _args)
SysEventBroker broker = SysEventBroker::construct();
SysEventInfo info1 = new SysEventInfo("Info-1"); // catch all;
SysEventInfo info2 = new SysEventInfo("Info-2"); // catch specific class
SysEventInfo info3 = new SysEventInfo("Info-3"); // catch specific type
// Setup
broker.addListener(info1, classNum(Object));
broker.addListener(info2, classNum(Runbase));
broker.addListener(info3, classNum(Object), "Fire 2"); // catch Fire 2
broker.addListener(info3, classNum(Object), "Fire 4"); // and Fire 4

broker.fireEvent(classNum(CustAutoCreate), "Fire 1", "This is my life");
broker.removeListener(info2, classNum(Runbase));
broker.fireEvent(classNum(CustAutoCreate), "Fire 2", "this is my time");
broker.fireEvent(classNum(CustAutoCreate), "Fire 3", "just show me the light");
broker.fireEvent(classNum(CustAutoCreate), "Fire 4", "and I go there");