PostTaskToRuntime
The PostTaskToRuntime method provides a way to schedule a task for execution on the BTS (Background Thread Script) thread. This is the primary mechanism for safely dispatching work from any thread (like the UI thread) to the thread where the JavaScript runtime lives.
It is essential for any operation that needs to interact with N-API or other BTS-thread-specific resources from outside the BTS thread. The method has overloads for both C++ std::function and C-style function pointers.
Method Signature
With std::function task
With C-function task
Parameters
Usage
Use this method whenever you need to perform an action on the BTS thread from another thread. A common scenario is responding to a UI event by updating state in the JavaScript runtime.
Example
See Also
IsRunningTasksOnBTSThread(): To check if the current thread is the BTS thread.
Compatibility
LCD tables only load in the browser