harmony 鸿蒙LoopObserver

  • 2025-06-12
  • 浏览 (4)

LoopObserver

The LoopObserver module defines an observer to listen for event processing timeout. It can be used as an input parameter in ErrorManager.on to listen for the event processing timeout of the current application’s main thread.

NOTE

The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Modules to Import

import { errorManager } from '@kit.AbilityKit';

LoopObserver.onLoopTimeOut

onLoopTimeOut?(timeout: number): void

Called when a timeout occurs for the main thread to process an event in the JS runtime.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Ability.AbilityRuntime.Core

Parameters

Name Type Mandatory Description
timeout number Yes Actual execution time of the main thread.

Example

import { errorManager } from '@kit.AbilityKit';

let observer: errorManager.LoopObserver = {
  onLoopTimeOut(timeout: number) {
    console.log('Duration timeout: ' + timeout);
  }
};

errorManager.on("loopObserver", 1, observer);

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

0  赞