heres my Multihtread class:
Code:
class MultiThread{
private:
bool blnDestroyed;
HANDLE Handle_Of_Thread_1;
typedef void (*MyThreadProc)();
MyThreadProc ThreadProcedure;
static DWORD WINAPI StaticThreadProc(LPVOID param)
{
static_cast<MultiThread*>(param)->MultithreadProcedure();
return 0;
}
void MultithreadProcedure()
{
for (;;)
{
if (blnDestroyed==true) break;
ThreadProcedure();
}
CloseHandle(Handle_Of_Thread_1);
TerminateThread( Handle_Of_Thread_1,1);
}
public:
int Start(MyThreadProc ThreadProc)
{
ThreadProcedure = ThreadProc;
Handle_Of_Thread_1=0;
CloseHandle(Handle_Of_Thread_1);
TerminateThread( Handle_Of_Thread_1,1);
blnDestroyed=false;
HANDLE hMyThread;
hMyThread = CreateThread(NULL, 0, StaticThreadProc, this, 0, NULL);
return 0;
}
int Stop()
{
blnDestroyed=true;
return 0;
}
MultiThread::~MultiThread() //for stop if the process isn't stoped before be destroyed
{
Stop();
}
};
heres how i use it:
Code:
#include "stdafx.h"#include "Console.h"
#include "Thread.h"
Console a;
int show()
{
for(;;)
{
cout << "hi";
Sleep(1000);
a.Clear();
}
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
MultiThread b;
b.Start(show());
a.Read();
return 0;
}
error message:
1 - "error C2664: 'MultiThread::Start' : cannot convert parameter 1 from 'int' to 'MultiThread::MyThreadProc'";
2 - " IntelliSense: argument of type "int" is incompatible with parameter of type "MultiThread::MyThreadProc"".
what i'm wrong?