IScheduledWorkItem::SetIdleWait method (mstask.h)

[[This API may be altered or unavailable in subsequent versions of the operating system or product. Please use the Task Scheduler 2.0 Interfaces instead.] ]

Sets the minutes that the system must be idle before the work item can run.


HRESULT SetIdleWait(
  [in] WORD wIdleMinutes,
  [in] WORD wDeadlineMinutes


[in] wIdleMinutes

A value that specifies how long, in minutes, the system must remain idle before the work item can run.

[in] wDeadlineMinutes

A value that specifies the maximum number of minutes that the Task Scheduler will wait for the idle-time period returned in pwIdleMinutes.

Return value

The SetIdleWait method returns S_OK.


The idle time specified here is used in conjunction with idle triggers and idle conditions. For more information, see Task Idle Conditions. Idle triggers are event-based triggers that are not associated with a scheduled time. Idle conditions, in contrast, are associated with the scheduled start time for the task.

You specify idle triggers by setting the TASK_TRIGGER_TYPE member of the TASK_TRIGGER to TASK_EVENT_TRIGGER_ON_IDLE. The idle trigger is fired when the system becomes idle for the amount of time specified by wIdleMinutes.

You set idle conditions by calling IScheduledWorkItem::SetFlags. If the TASK_FLAG_START_ONLY_IF_IDLE flag is set, the work item runs at its scheduled time only if the system becomes idle for the amount of time specified by wIdleMinutes. The Task Scheduler service will wait up to the number of minutes specified in wDeadlineMinutes past the scheduled start time to see if the system becomes idle.

Applications must call the IPersistFile::Save method after calling SetIdleWait to update the idle wait interval.


For an example of how to set the idle wait time when creating an idle trigger, see Creating an Idle Trigger Example.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header mstask.h
Library Mstask.lib
DLL Mstask.dll
Redistributable Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95

See also