“b861b626720154d3592a83d400855b2aa408df69”上不存在“...ts-container-rowsplit.md”
提交 31c942ee 编写于 作者: Z zhangxin_T

docs modify

Signed-off-by: Nzhangxin_T <zhangxin312@huawei.com>
上级 6c655005
...@@ -301,6 +301,13 @@ function stopBackgroundRunning() { ...@@ -301,6 +301,13 @@ function stopBackgroundRunning() {
}); });
} }
async function processAsyncJobs() {
// 此处添加执行具体长时任务的代码。
// 长时任务执行完,调用取消接口,释放资源。
stopBackgroundRunning();
}
let mMyStub; let mMyStub;
class MyStub extends rpc.RemoteObject { class MyStub extends rpc.RemoteObject {
...@@ -316,11 +323,11 @@ class MyStub extends rpc.RemoteObject { ...@@ -316,11 +323,11 @@ class MyStub extends rpc.RemoteObject {
// code 的具体含义用户自定义 // code 的具体含义用户自定义
if (code === 1) { if (code === 1) {
// 接收到申请长时任务的请求码 // 接收到申请长时任务的请求码
startContinuousTask(); startBackgroundRunning();
// 此处执行具体长时任务 // 此处执行具体长时任务
} else if (code === 2) { } else if (code === 2) {
// 接收到取消长时任务的请求码 // 接收到取消长时任务的请求码
stopContinuousTask(); stopBackgroundRunning();
} else { } else {
console.log('ServiceAbility unknown request code'); console.log('ServiceAbility unknown request code');
} }
...@@ -332,9 +339,9 @@ export default { ...@@ -332,9 +339,9 @@ export default {
onStart(want) { onStart(want) {
console.info('ServiceAbility onStart'); console.info('ServiceAbility onStart');
mMyStub = new MyStub("ServiceAbility-test"); mMyStub = new MyStub("ServiceAbility-test");
// 在执行后台长时任前,调用申请接口。
startBackgroundRunning(); startBackgroundRunning();
// 此处执行后台具体的长时任务。 processAsyncJobs();
stopBackgroundRunning();
}, },
onStop() { onStop() {
console.info('ServiceAbility onStop'); console.info('ServiceAbility onStop');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册