.


:




:

































 

 

 

 





Windows NT (waitable timers), , .

, , Sleep. serverNP ( 11.3) . , . , , .

(synchronization timer), (manual-reset notification timer) . , /, .

, CreateWaitableTimer.

HANDLE CreateWaitableTimer(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCTSTR lpTimerName);

, bManualReset, , . 14.3 , , , . , OpenWaitableTimer, , .

, SetWaitableTimer , .

BOOL SetWaitableTimer(HANDLE hTimer, const LARGE_INTEGER *pDueTime, LONG IPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume);

hTimer , CreateWaitableTimer.

, pDueTime, , , , , 100 , FILETIME. FILETIME 3 6 timep ( 6.2).

, , . 0, . , CancelWaitableTimer. .

, pfnCompletionRoutine, , , . , , plArgToComplretionRoutine.

, SleepEx, . . SetWaitableTimer. 14.3, Web-, , , .

, fResume, . .

CancelWaitableTimer SetWaitableTimer, . , SetWaitableTimer.

:

14.3 .

14.3. TimeBeep:

/* 14. TimeBeep.. . */

/* : TimeBeep ( ). */

 

#include "EvryThng.h"

static BOOL WINAPI Handler(DWORD CntrlEvent);

static VOID APIENTRY Beeper(LPVOID, DWORD, DWORD);

volatile static BOOL Exit = FALSE;

HANDLE hTimer;

 

int _tmain(int argc, LPTSTR argv[]) {

DWORD Count = 0, Period;

LARGE_INTEGER DueTime;

/* <Ctrl-c> . . 4. */

SetConsoleCtrlHandler(Handler, TRUE);

Period = _ttoi(argv[1]) * 1000;

DueTime.QuadPart = (LONGLONG)Period * 10000;

/* DueTime . (10-3 ), a DueTime 100 c (10-7 ) FILETIME. */

hTimer = CreateWaitableTimer(NULL, FALSE /* " " */, NULL);

SetWaitableTimer(hTimer, &DueTime, Period, Beeper, &Count, TRUE);

while (!Exit) {

_tprintf(_T("Count = %d\n"), Count);

/* . */

/* . */

SleepEx(INFINITE, TRUE);

}

_tprintf(_T(". = %d"), Count);

CancelWaitableTimer(hTimer);

CloseHandle(hTimer);

return 0;

}

 

static VOID APIENTRY Beeper(LPVOID lpCount, DWORD dwTimerLowValue, DWORD dwTimerHighValue) {

*(LPDWORD)lpCount = *(LPDWORD)lpCount + 1;

_tprintf(_T(" : %d\n"), *(LPDWORD) lpCount);

(1000 /* . */, 250 /* (). */);

return;

}

 

BOOL WINAPI Handler(DWORD CntrlEvent) {

Exit = TRUE;

_tprintf(_T(" \n"));

return TRUE;

}





:


: 2015-09-20; !; : 519 |


:

:

, .
==> ...

1524 - | 1317 -


© 2015-2024 lektsii.org - -

: 0.01 .