Does SetTimer (with callback function) work by starting a new thread?

Viewed 2812

When using SetTimer this way:

SetTimer(hWnd, IDT_TIMER_LONGPROCESSING, 2000, (TIMERPROC) NULL);
DoSomethingElse();

the execution continues immediately (i.e. it's non-blocking and DoSomethingElse() is executed immediately), but when this message arrives

case WM_TIMER:
    if (wParam == IDT_TIMER_LONGPROCESSING)
         DoAOneSecondLongJob();

then it blocks the "window message loop" again during the 1-second long processing, resulting in a unresponsive interface. That's normal behaviour with SetTimer just posting a timer message.

But I see SetTimer can also be used in a second way, with a callback function:

VOID CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{ 
    DoAOneSecondLongJob();
}

// in another function    
SetTimer(hwnd, IDT_TIMER_LONGPROCESSING, 2000, (TIMERPROC) MyTimerProc);

Question:

  • Will this method be blocking as well?

or

  • Will it solve the unresponsive-interface-during-1-second problem? If so, how? Is there a new thread creation involved under the hood?
1 Answers
Related