September 14th, 2016

What exactly does the msWindowLength parameter to SetThreadpoolTimer mean?

A customer was looking for clarification on the msWindow­Length parameter to the Set­Threadpool­Timer function.

msWindowLength [in, optional]

The maximum amount of time the system can delay before calling the timer callback. If this parameter is set, the system can batch calls to conserve power.

“It’s not clear whether the window extends both before and after the due time (presumably, half the window size on either side), or whether the timer will always delay at least until the due time, and possibly up to the due time plus the window value.”

The window specifies the maximum delay, and generally speaking, delay means late, never early. (When was the last time you heard that your flight was delayed, by which they meant that it landed 30 minutues early?)

In other words, the latter interpretation is the correct one. The threadpool will schedule the callback at some point between the due time and the due time plus the window.

(For the record, the Set­Coalescable­Timer and Set­Waitable­Timer­Ex functions work the same way.)

The customer thanked us for the clarification. That’s what they thought, but they wanted to make sure.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.