The **workScheduler** module provides the APIs for registering, canceling, and querying Work Scheduler tasks, which do not have real-time constraints.
The system executes Work Scheduler tasks at an appropriate time, subject to the storage space, power consumption, temperature, and more.
> **NOTE**
>
> - The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs of this module can be used only in the stage model.
> - For details about the constraints on the Work Scheduler usage, see [Work Scheduler Overview](../../task-management/work-scheduler-overview.md).
## Modules to Import
```js
importworkSchedulerfrom'@ohos.workScheduler';
```
## workScheduler.startWork
startWork(work: WorkInfo): boolean
Instructs the **WorkSchedulerService** to add the specified task to the execution queue.
| callback | AsyncCallback\<[WorkInfo](#workinfo)> | Yes | Callback used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
| Promise\<[WorkInfo](#workinfo)> | Promise used to return the result. Returns the task status obtained from the **WorkSchedulerService** if the specified task ID is valid; returns **null** otherwise.|
**Example**
```js
workScheduler.getWorkStatus(50).then((res)=>{
for(letiteminres){
console.info(`workschedulerLog getWorkStatus success, ${item} is: ${res[item]}`);
| callback | AsyncCallback\<void> | Yes | Callback used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
| Promise\<boolean> | Promise used to return the result. Returns **true** if the last execution of the specified task timed out; returns **false** otherwise.|
**Example**
```js
workScheduler.isLastWorkTimeOut(500)
.then(res=>{
console.info(`workschedulerLog isLastWorkTimeOut success, data is: ${res}`);
Provides detailed information about the task. For details about the constraints on configuring **WorkInfo**, see [Work Scheduler Overview](../../task-management/work-scheduler-overview.md).
@@ -152,7 +152,7 @@ Inherit from **workAbility** and implement the lifecycle callbacks for the WorkS
Import the module.
```ts
import { workAbility } from '@ohos/library'
import { workAbility } from '@ohos/library';
```
Add the **Upgrade** button, which, when being clicked, will call the API encapsulated in **library** to start the Work Scheduler task. In the API, **bundleName** and **abilityName** are passed in, where the value of **abilityName** is **WorkTest**.
...
...
@@ -163,7 +163,7 @@ Inherit from **workAbility** and implement the lifecycle callbacks for the WorkS