ITaskScheduler::AddWorkItem method

The AddWorkItem method adds a task to the schedule of tasks.

Syntax


HRESULT AddWorkItem(
  [in]  LPCWSTR pwszTaskName,
  [in]  IScheduledWorkItem *pWorkItem
);

Parameters

pwszTaskName [in]

A null-terminated string that specifies the name of the task to add. The task name must conform to Windows NT file-naming conventions, but cannot include backslashes because nesting within the task folder object is not allowed.

pWorkItem [in]

A pointer to the task to add to the schedule.

Return value

The AddWorkItem method returns one of the following values.

Return codeDescription
S_OK

The operation was successful.

ERROR_FILE_EXISTS

A task with the specified name already exists. The actual return value is HRESULT_FROM_WIN32(ERROR_FILE_EXISTS).

E_INVALIDARG

One or more of the arguments is not valid.

E_OUTOFMEMORY

Not enough memory is available to complete the operation.

 

Remarks

Task scheduler provides two methods for adding work items: NewWorkItem and AddWorkItem. Of these methods, each has its specific advantage. AddWorkItem prevents naming collisions, but it also requires two disk write operations per call. One write operation is performed when the call to AddWorkItem creates an empty work item object on the disk, followed by another write operation when IPersistFile::Save is called.

NewWorkItem does not prevent naming collisions, but it requires only one disk write operation when IPersistFile::Save is called. Although NewWorkItem is more efficient with disk write operations, the application runs the risk of having another application create a work item with the same name before the call to IPersistFile::Save is made.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Redistributable

Internet Explorer 4.0 or later on Windows NT 4.0 and Windows 95

Header

Mstask.h

Library

Mstask.lib

DLL

Mstask.dll

See also

IScheduledWorkItem
ITaskScheduler
ITaskScheduler::NewWorkItem

 

 

Community Additions

ADD
Show:
© 2014 Microsoft