Hello!
I have made a GenThread class which combines thread and timer to do an async call.
This code works like it shall
My question is: is it correct I cannot use a/the base delegate but have to define DelegateTimer?
Thanks a lot!
Regards.
delegate DelegateThreader(P as Thread)
delegate DelegateTimer
constructor Constructor(optional POnThreader as DelegateThreader=nil, optional POnTimer as DelegateTimer=nil)
Me.IsRunning = True
Me.Ti=new Timer
Me.Th = new Thread
Me.OnThreader = POnThreader
Me.OnTimer = POnTimer
Me.Run()
//end constructor Constructor(optional POnThreader as DelegateThreader=nil, optional POnTimer as DelegateTimer=nil)
method PerformAction()
// Part of the actionNotificationReceiver interface.
if Me.Th<>nil then
if Me.Th.State=Thread.NotRunning then
Ti.Enabled=False
Me.OnTimer.Invoke()
Me.IsRunning = False
end if
end if
//end method PerformAction()
method Run()
AddHandler Me.Th.Run, Me.OnThreader
Ti.addActionNotificationReceiver Me
Ti.Enabled=True
Ti.Mode=Timer.ModeMultiple
Ti.Period=1000
Me.Th.Run()
//end method Run()
Property OnThreader as DelegateThreader
Property OnTimer as DelegateTimer
Property Th as Thread
Property Ti as timer
Shared Property IsRunning As Boolean