Hello,
I need to write a C++ extension that can be called via a lua script. The function I need is a simple sleep functions such as:
1 2 3 4
|
void sleep( FLOAT seconds )
{
Sleep( (DWORD)(seconds * 1000));
}
|
What complicates it for me however, is that I think that I need to run this within a new thread, because otherwise, my entire application will sleep. What I want is for my application to continue processing in the background while my script "sleeps" for a specified amount of time.
Basically what I think I want to do is this:
1. Create a new thread
2. Send my script to the new thread
3. Execute the sleep function (hopefully passing the milliseconds in from my lua script)
4. When sleep is completed --> exit out / complete the thread so that the remainder of my script can be executed.
This function would be called via a lua script hopefully using some format like: sleepThread( 60 )
Is there anyone that can help me with how to create the new thread, properly call the sleep function, exit the thread ... and set it up so that a value in seconds/milliseconds can be passed in.
Thank you so much for your help!
~L