StartBgImmediate

nn::boss::Task::StartBgImmediate Member Function

Syntax

nn::Result StartBgImmediate(
     void
);

Parameters

None.

Return Values

Returns the function's execution result. Returns one of the Result values listed below.
Value Description
Result::IsSuccess Successfully issued the instruction to start the task.
ResultInvalidTaskId The task ID pointer is NULL or a zero-length string.
ResultTaskNotExist The specified task ID was not found. Confirm whether it is registered yet.
ResultIpcNotSessionInitialized The session has not been initialized. This result is returned if this function is called before the Initialize function. Always call the Initialize function first thing when you use the BOSS library.
A value other than the above. Unexpected error (see boss_Result.h for error details).

Description

Gives an instruction to start the task immediately in the background.

Scheduled tasks run automatically in the background whenever infrastructure connections are possible. Except for the first time a task is run, this function behaves the same as the Start function. The first time a task is run, the Start function runs after waiting for the task execution interval.
When calling this function, the call causes it to wait for the first task execution time, so the initial task after calling is run immediately as soon as an Internet connection is established.
(Consequently, calling this function while connected to the Internet and when the application has allowed BOSS operations while the application is running, the task runs immediately in the background.
However, even in such circumstances, task execution will wait until any other running tasks complete.)

Note that calling this function on tasks already instructed to run (such as tasks for which you have already called the Start function) does not change anything.
To tell such tasks to run immediately in the background, you must first call the Cancel function and then call this function.

When a task finishes running, the execution count specified in the task's attributes is decremented by 1 regardless of whether task execution resulted in an error. Unless this results in a remaining execution count of 0, the task will run again after the execution interval specified in the task's attributes has elapsed.
Note:After its execution count reaches zero, a task is sometimes deleted automatically if the internal database is filled to capacity.

Note: In the following circumstances, tasks won't be executed even if the instruction is issued to start a task.
• The task's execution count is 0.
• The task's execution priority is PRIORITY_STOPPED.
• Parental Controls are in effect and are not disabled by the task attributes.
• The user has not yet agreed to the EULA, and the requirement to agree to the EULA is not disabled by the task attributes.
• Task execution was stopped by the policy list.
• The server hosting the download service issued a "service suspended" notice.
• The administrator has temporarily stopped all tasks.

The GetCount function can be used to confirm whether the task execution count is the relevant case among those listed above. You can tell when the administrator has temporarily stopped all tasks because TASK_PAUSED is returned by the GetState function for all running tasks.

The following methods can be used to wait for task completion.
・Wait for execution to complete with using WaitFinish function.
・Specify a maximum waiting time and wait for execution to complete using the WaitFinish function.
・Use the GetState function to poll for completed tasks.
・Wait for a "new arrival" event using an Event registered by the RegisterNewArrivalEvent function.
Once you detect that a task has completed, you can check its state using the GetState function, its execution result code using the GetResult function, and the HTTP communication result code using the GetHttpStatusCode function. You can also get other details with the GetStateDetail function.

Revision History

2011/10/27
Initial version.

CONFIDENTIAL