if you try to delete a timer/queue that is currently executing says it fails (returns 0) but subsequent attempts to delete will crash.
So I want to test
A) to check if a timer procedure is currently executing
B) to check if a handle to queue or timer is valid
Ideas?
Code: Select all
Import "Kernel32.lib"
CreateTimerQueue_() As "CreateTimerQueue"
DeleteTimerQueueEx_( hTimerQueue, completionEvent) As "DeleteTimerQueueEx"
CreateTimerQueueTimer_( *hTimer, hTimerQueue, timerCallback, param, dueTime, period, flags) As "CreateTimerQueueTimer"
DeleteTimerQueueTimer_( hTimerQueue, *hTimer, completionEvent) As "DeleteTimerQueueTimer"
EndImport
Procedure test(n)
Static x
x+1
Debug "P "+x
; Delay(1100) ; stay running while attempt to delete.
EndProcedure
Define *Timer,
*TimerQueue = CreateTimerQueue_(),
period = 1000
CreateTimerQueueTimer_(@*Timer, *TimerQueue, @test(), #False, period, period, 0)
Debug "Q "+*TimerQueue
Debug "T "+*Timer
Delay(3000)
Debug "delete"
Debug "------"
Debug "T1 "+DeleteTimerQueueTimer_( *TimerQueue, *timer, #Null ) ; if delay in test() is enabled, this will say delete has failed (returns 0)
;Debug "T2 "+DeleteTimerQueueTimer_( *TimerQueue, *timer, #Null ) ; uncomment to watch it crash.
Debug "------"
Debug "Q1 "+DeleteTimerQueueEx_( *TimerQueue, #Null ) ; comment both DeleteTimerQueueTimer_() this will return 0 IF delay is enabled in test()
;Debug "Q2 "+DeleteTimerQueueEx_( *TimerQueue, #Null ) ; uncomment to crash.
Debug "--------"
Debug "deleted"
Delay(2000)
Debug "Done"