help
help copied to clipboard
uv_async_send problem in windows not in mac or linux
Hi,
I have created an electron app and below code works as expected on mac and linux. But in windows it works only once (first time app start). From the second run of the electron app uv_async_send not execute the callback until restart the pc. `
class Reader {
uv_async_t* asyncHandle = nullptr;
// Start
void start() {
uv_loop_t* loop = uv_default_loop();
asyncHandle = new uv_async_t;
asyncHandle->data = this;
uv_async_init(loop, asyncHandle, [] (uv_async_t* handle) {
if(handle->data) {
printf("Callback is called");
}
}
}
// Stop
void stop(){
uv_close(reinterpret_cast<uv_handle_t*>(asyncHandle), [] (uv_handle_s* handle) {
delete static_cast<uv_handle_t*>(handle);
});
asyncHandle = nullptr;
}
// calling from different thread
static void downloadProgress(Reader* pointer, int progress){
// Do something
printf("Has Progress");
uv_async_send(pointer->asyncHandle);
}}
`
I am properly call the start and stop functions.
Output First time
Has Progress Callback is called Has Progress Callback is called
Run on second time, call back not called
Has Progress Has Progress Has Progress Has Progress