简体   繁体   中英

Electron freezes when executing native NodeJS module

I have some C++ code written as a NodeJS native module. The function to initialize everything opens some threads which have infinite while loops, which need to be run until the program closes. In command line everything works just fine, but when I call the function in electron, it hangs. Is there any way to call C++ from electron that isn't blocking?

I believe the main issue is the fact that the initialize function doesn't ever return unless the app is quit, and that makes electron angy (no typo).

Figured out the soultion. Thanks @t.niese! Rather than using Thread.join() , which holds up the function until the app quits, I needed to use Thread.detach() , and make a function to clean everything up when done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM