例如,假设我有以下
TimerProc
:
#include <Windows.h>
#define IDT_TIMER1 1001
BOOL g_fKillTimer = FALSE;
VOID DoTimerTask(); // Among other things, sets the flag `g_fKillTimer` when needed
// Timer is started elsewhere with a call to:
// SetTimer(hWnd, IDT_TIMER1, 10000, TimerProc);
VOID CALLBACK TimerProc(
_In_ HWND hWnd,
_In_ UINT uMsg,
_In_ UINT_PTR idEvent,
_In_ DWORD dwTime
)
{
if (TRUE == g_fKillTimer)
{
KillTimer(hWnd, IDT_TIMER1);
}
DoTimerTask();
}
此代码是否会成功终止计时器
IDT_TIMER1
?还是我在定时器程序本身内调用 KillTimer
的事实可能会为此带来问题?函数DoTimerTask()
还会被调用吗?