Event sample
2016
Today, trying to understand also events in Vulcan.NET/X#, I wrote the following sample that should give an idea how events work in Vulcan.NET and X#.
#using EventSample
begin namespace EventSample
function Start( ) as void
local oClass2 as Sample2ClassSystem.Console.WriteLine(“Start of the SampleEvent application”)
oClass2 := Sample2Class{}
oClass2:RegisterEvent()return
public delegate SampleHandle( cParameter as string ) as void
class SampleClass
public event oSampleEvent as SampleHandleconstructor()
return
method CallSampleEvent() as void
oSampleEvent( “Hi there” )
return
end class
class Sample2Class
constructor()
return
method RegisterEvent() as void
local oClass as SampleClassoClass := SampleClass{}
oClass:oSampleEvent += self:method2
oClass:CallSampleEvent()return
public method method2( cParameter as string ) as void
System.Console.WriteLine( “method2:” + cParameter )
return
end class
end namespace