You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, please provide an example of using onMessage and postMessage from both the worker side and the main thread side using Typescript. The object returned from spawn doesn't seem to include those methods and I dont see how to call them from within expose as well.
Thank you
The text was updated successfully, but these errors were encountered:
Hi Andy, I think what i was trying to do is use setInterval to do a repeated task in a thread and then send a message to the thread to stop the setInterval. I think if I just stop the thread (using Thread.terminate) and don't call clearInterval, I risk memory leaks. I also needed to send data from the thread to the originating code. I guess any use case where you need to send a message to a thread or from a thread to the originating code would be the general use case for posting message both to and from threads.
Because using the low-level postMessage seems like a rather bad idea. For your use case, however, I don't see a need for any of that. Why not just do something like this?
Btw, I don't think you're at risk of memory leaks if you call Thread.terminate() as you terminate the whole thread anyway. That should free up all resources used by the thread.
Hello, please provide an example of using onMessage and postMessage from both the worker side and the main thread side using Typescript. The object returned from spawn doesn't seem to include those methods and I dont see how to call them from within expose as well.
Thank you
The text was updated successfully, but these errors were encountered: