L
Lee Garrington
Hello,
I am having a bit of a problem with multithreading in C++. After reading
through 2 tutorials and implementing it in what looks the same way, it still
does not compile. Basically, how do I start a function as a separate thread
in a class?
I have the following functions defined...
void Solver::Start()
{
hThreadHandle = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &iThreadId);
}
static DWORD WINAPI ThreadProc(Solver *s)
{
return s->Solve();
}
DWORD Solver::Solve()
{
//do some stuff
return 0;
}
I just keep getting a typecast error. Can someone either tell me where I
went wrong or provide me with an explanation of how to do it properly?
Thx in advance
Lee
I am having a bit of a problem with multithreading in C++. After reading
through 2 tutorials and implementing it in what looks the same way, it still
does not compile. Basically, how do I start a function as a separate thread
in a class?
I have the following functions defined...
void Solver::Start()
{
hThreadHandle = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &iThreadId);
}
static DWORD WINAPI ThreadProc(Solver *s)
{
return s->Solve();
}
DWORD Solver::Solve()
{
//do some stuff
return 0;
}
I just keep getting a typecast error. Can someone either tell me where I
went wrong or provide me with an explanation of how to do it properly?
Thx in advance
Lee