- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
INTEGER(PHANDLE) hTimer(2)
TYPE (T_LARGE_INTEGER) liDueTime1, liDueTime2
INTEGER*8 qwDueTime
INTEGER*4 dwDueTime(2)
EQUIVALENCE (qwDueTime,dwDueTime)
LOGICAL*4 TimerLoop
! Body of TimersEx
TimerLoop = .TRUE.
qwDueTime = -10 * 10000000
liDueTime1.LowPart = dwDueTime(1)
liDueTime1.HighPart = dwDueTime(2)
qwDueTime = -15 * 10000000
liDueTime2.LowPart = dwDueTime(1)
liDueTime2.HighPart = dwDueTime(2)
! create waitable timershTimer(1) = CreateWaitableTimer (NULL, .TRUE., "WaitableTimer")
IF (hTimer(1) .EQ. 0) THENstatus = GetLastError()
PRINT 100, ' CreateWaitableTimer (Timer1) failed', status GOTO 900 ENDIFhTimer(2) = CreateWaitableTimer (NULL, .TRUE., "WaitableTimer")
IF (hTimer(2) .EQ. 0) THENstatus = GetLastError()
PRINT 100, ' CreateWaitableTimer (Timer2) failed', statusTimerLoop = .TRUE.
ENDIF ! set timers to wait for 10 and 15 secondsstatus = SetWaitableTimer (hTimer(1), liDueTime1, 0, NULL, NULL, 0)
IF (.NOT. status) THEN PRINTTimerLoop = .TRUE.
ENDIF
status = SetWaitableTimer (hTimer(2), liDueTime2, 0, NULL, NULL, 0)
IF (.NOT. status) THEN PRINT 100, ' SetWaitableTimer Timer2 failed', GetLastError()TimerLoop = .TRUE.
ENDIF DO WHILE (TimerLoop .EQ. .TRUE.) ! wait for timerstatus = WaitForMultipleObjects (2, %ref(hTimer), .FALSE., INFINITE)
IF (status .EQ. 0) THEN PRINT 100, ' Timer1 was signaled', status ! reset timer for 10 secondsstatus2 = SetWaitableTimer (hTimer(1), liDueTime1, 0, NULL, NULL, 0)
IF (.NOT. status2) THEN PRINT 100, ' SetWaitableTimer Timer1 failed', GetLastError()TimerLoop = .FALSE.
ENDIF ELSE IF (status .EQ. 1) THEN PRINT 100, ' Timer2 was signaled', status ! reset timer for 15 secondsstatus2 = SetWaitableTimer (hTimer(2), liDueTime2, 0, NULL, NULL, 0)
IF (.NOT. status2) THEN PRINT 100, ' SetWaitableTimer Timer2 failed', GetLastError()TimerLoop = .FALSE.
ENDIF ELSE PRINT 100, ' WaitForMultipleObject failed', GetLastError()TimerLoop = .FALSE.
ENDIF END DO 100 FORMAT ( A, ':', X, '[', D, ']' ) 900 CONTINUE end program TimersExLink Copied
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page