problem CreateTimerQueue() in InitInstance
I have a MFC dll (no window objects, only CWinApp) and I wish to
include some clock mechanism, having not CWnd derived objects I have
not access to SetTimer() etc. so I considered CreateTimerQueue() +
CreateTimerQueueTimer, see the code below, the code compiles
(VS2008SP1) without warnings but once started CreateTimerQueue()
appears to deadlock the system, I would guess the problem is related
to InitInstance() but I am not sure, also I have no idea about
alternative CWinApp methods which I could use to start the timer, any
suggestions ?
Thank you.
//--------------------------------------------------------------------------
// DLL initialization goes here
// so include the code to start timers
//
BOOL Mydll::InitInstance()
{
// start clock
// Create the timer queue.
hTimerQueue = CreateTimerQueue();
if (hTimerQueue != NULL)
{
CreateTimerQueueTimer(&hTimer,
hTimerQueue,
(WAITORTIMERCALLBACK)TimerProc,
0, // no values to TimerProc
1000, // first call (1000 ms)
1000, // timer period (1000 ms)
0);
}
return(TRUE);
}