Jump to content

bind command for Threads seems not having some overloads that docs have


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

Also it should be Start instead of Resume in GetState and false as param in CreateThread for preventing run. Something like that:

#include "Leadwerks.h"

using namespace Leadwerks;

void ThreadFunc() {
    Sleep(1000);
}

void PrintState(shared_ptr<Thread> thread) {
    switch (thread->GetState()) {
    case THREAD_READY:
        Print("Ready");
        break;
    case THREAD_RUNNING:
        Print("Running");
        break;
    case THREAD_FINISHED:
        Print("Finished");
        break;
    }
}

int main(int argc, const char* argv[]) {
    //Create thread
    auto thread = CreateThread(std::bind(ThreadFunc), false);
    PrintState(thread);

    //Execute thread
    thread->Start();
    PrintState(thread);

    //Wait for thread to finish
    thread->Wait();
    PrintState(thread);

    return 0;
}

 

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...