Re: problem CreateTimerQueue() in InitInstance
InitInstance of a DLL is called on DllMain time, when you are very
restricted in what you can call.
"celiro" <celiro@tiscali.it> wrote in message
news:a23527b3-5f62-4a55-a6d3-1157404353ee@x16g2000prn.googlegroups.com...
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);
}