ITask::SetMaxRunTime 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.] ]

This method sets the maximum time the task can run, in milliseconds, before terminating.

Syntax

HRESULT SetMaxRunTime(
  [in] DWORD dwMaxRunTimeMS
);

Parameters

[in] dwMaxRunTimeMS

A DWORD value that specifies the maximum run time (in milliseconds), for the task. This parameter may be set to INFINITE to specify an unlimited time.

Return value

The SetMaxRunTime method returns one of the following values.

Return code Description
S_OK
The operation was successful.
E_INVALIDARG
The arguments are not valid.
E_OUTOFMEMORY
Not enough memory is available.

Remarks

When the maximum run time is exceeded, the Task Scheduler attempts to terminate the application associated with the task. If a WM_CLOSE message cannot be sent (for example, the application has no windows) or the application has not exited within three minutes of the receiving WM_CLOSE, the Task Scheduler terminates the application using TerminateProcess.

After setting the maximum run time, be sure to call IPersistFile::Save to save the modified task object to disk.

Examples

For an example of how to set the maximum run time, see C/C++ Code Example: Setting MaxRunTime.

Requirements

Requirement Value
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

IGetMaxRunTime

ITask