diff --git a/entry/src/main/cpp/napi_init.cpp b/entry/src/main/cpp/napi_init.cpp index b650e1dd26f6c575754338e8589f86dbae76f96b..3f4dbd998f9158347d68c2b28000f5ef544c446a 100644 --- a/entry/src/main/cpp/napi_init.cpp +++ b/entry/src/main/cpp/napi_init.cpp @@ -102,9 +102,10 @@ static napi_value ThreadSafeCase(napi_env env, napi_callback_info info) { // [End thread_safe_case] // [Start uv_loop_async] +//Global variable, used to store loop information and async handle. uv_loop_t *loop = nullptr; uv_async_t *async = nullptr; -// [End uv_loop_async_t] +// [End uv_loop_async] // [Start async_handler] void async_handler(uv_async_t *handle) { diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index adbf7f1e6f216c607c314de7a48d5fb4945b6830..c3d7812f464376fa3cf9027500a46d6e377b182b 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -63,9 +63,10 @@ struct Index { .width('100%') .onClick(() => { // [Start testNapi_thread_safe_case] + //Call Native side function and pass ArkTS side function to Native side. testNapi.threadSafeCase(this.work); - this.getUIContext().getPromptAction().showToast({ // [End testNapi_thread_safe_case] + this.getUIContext().getPromptAction().showToast({ message: $r('app.string.threadSafe_message'), duration: 2000 }) @@ -74,7 +75,10 @@ struct Index { .width('100%') .margin({ top: 12 }) .onClick(() => { + // [Start lib_case] + //Call Native side function and pass ArkTS side function to Native side. testNapi.libUvCase(this.work); + // [End lib_case] this.getUIContext().getPromptAction().showToast({ message: $r('app.string.libUV_message'), duration: 2000