Re: A _very_ basic question about WM_TIMER and threading




"andrew" <test@xxxxxxxx> wrote in message news:%23B8vYkcDJHA.3392@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

If I create a timer by calling CWnd::SetTimer() (e.g. in my CView::OnInitialUpdate()) why do I need to deal with re-entrancy issues in the corresponding OnTimer() handler? I thought that all calls to OnTimer() handlers execute on the same thread (main GUI thread?). How is it possible then for the handler to be called while the thread is already executing the handler?
I've run into this problem recently while debugging my app.
I'd welcome any pointers and/or explanations.

Thanks.

Making any call in your handler that spins a message loop will cause you to reenter, as others have said on other threads.

While they suggest displaying a dialog box for example may cause it, that's not the only thing that can do it. In my experience, it's often something innocuous looking like calling an out of process COM object, or calling something that calls an out of process COM object in its implementation.

Anthony Wieser
Wieser Software Ltd




.



Relevant Pages