What’s the difference between CreateTimerQueueTimer and SetThreadpoolTimer?

A customer wanted to know what the difference is between CreateTimerQueueTimer and SetThreadpoolTimer, and what factors they should consider when choosing between them. (The customer explained that their immediate need was to create a periodic timer that fires every five seconds. It is not critical that the timer fire exactly at five second intervals.)

The CreateTimerQueueTimer function is a wrapper that calls SetThreadpoolTimer under the covers, so at the end of the day, you're using SetThreadpoolTimer whether you like it or not.

The CreateTimerQueueTimer function is just a compatibility function for programs written to the old thread pool API.

The customer thanked us for the explanation and decided to go with SetThreadpoolTimer.

Comments (5)
  1. Matthew Vincent says:

    Good thing they didn’t thank you for the explanation and go with the CreateTimerQueueTimer function instead….

  2. Erik F says:

    Wait, the customer actually added important information about why they’re asking the question? That’s incredible! (Maybe they could let their friends know of this powerful technique.)

  3. skSdnW says:

    It like to get more history on the threadpool stuff. Was it mostly for IE/Shell in 2000 and then started moving its way down the dll layers in XP and Vista? Or was the Vista TP created fresh by a different team and the shell guys dumped their code and became compatibility stubs?

  4. IanBoyd says:

    Although the fact that CreateTimerQueueTimer internally uses SetThreadpoolTimer is an internal implementation detail.

    If you use SetThreadpoolTimer you are always going to be using the thread pool. If in the future there becomes a better way of running timers (that CreateTimerQueueTimer takes advantage of), you’re locking yourself of that improvement by mandating the use of an implementation detail you really don’t care about.

    1. cheong00 says:

      Don’t worry. If there exists future advance applicable on CreateTimerQueueTimer(), the change is most probably applicable to SetThreadpoolTimer() as well so both API will become a wrapper to that “newer API”.

Comments are closed.

Skip to main content