Does anybody know where I can get some basic source code on the creation and use of threads (I know about threads, just never coded them, and reading up on them, some of the inputs into CreateThread are confusing)?

Recommended Answers

All 4 Replies

tutorial

If you enter "CreateThread tutorial" in google, you get plenty results.

class myClass
{
public:
void init();

private:
void WINAPI Thread();
};

void WINAPI myClass::Thread()
{
    //do whatever
}

void init()
{
   CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Thread, 0, 0, 0);
}

This is just a quick psuedo for a much larger program. The error I get is ...

error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'LPTHREAD_START_ROUTINE'

This is how i read to start a simple thread, did I do something wrong?

Thanks.

I needed to declare the function, whose address was being passed to the thread, as static, in case anyone has this problem in the future.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.