In my nodejs NAPI C++ addon, I need to maintain a long-running process in a background thread. Periodically, the process needs to let the front-end javascript know the current status.
I am implementing a Napi::AsyncWorker
based class. The idea is that my process will run within the Execute
method and periodically invoke the javascript callback that has been provided to the instance.
Is it safe to invoke callback methods from the Execute
method? Is there any other way? Regards.
答案 0 :(得分:-1)
您最好使用AsyncWorkerProgress