ahoy
i have taken the liberty to transcribe a part of your code into a usable function
acts partly like adlibregister but does only check and run on call (so it does not interrupt current processes)
original code:
If TimerDiff($CleanupTimer) > 1000 Then ;If it has been more than 1000ms since Cleanup() was last called, call it now
$CleanupTimer = TimerInit() ;Reset $CleanupTimer, so it is ready to be called again
Cleanup() ;Clean up the dead connections
EndIf
my function:
Func _starttimer($sttimr = 'Cleanup', $sttimrdiff = 1000)
$sttimrn = $sttimr & 'Timer'
If IsDeclared($sttimrn) = 0 Then Assign($sttimrn, _Timer_Init(), 2)
If TimerDiff(Eval($sttimrn)) > $sttimrdiff Then
Assign($sttimrn, TimerInit())
Return Execute($sttimr & '()')
EndIf
EndFunc
you can call it like this in your loop and it will start the given function after X msec
_starttimer('Cleanup', 1000)
best regards,
stefan