Thread
-
UNIT SimpleThread::ThreadFunc(LPARAM lp) { While(1) { printf("Test"); } } SimpleThread::Start() { DWORD dwThreadId, dwThrdParam = 1; threadHandle = CreateThread( NULL, 0, SimpleThread::ThreadFunc, dwThrdParam, 0, &dwThreadId); } When call the thread it does't get called. Also somtimes it called but the while loop terminate within a while.Can any give me solution to this
-
UNIT SimpleThread::ThreadFunc(LPARAM lp) { While(1) { printf("Test"); } } SimpleThread::Start() { DWORD dwThreadId, dwThrdParam = 1; threadHandle = CreateThread( NULL, 0, SimpleThread::ThreadFunc, dwThrdParam, 0, &dwThreadId); } When call the thread it does't get called. Also somtimes it called but the while loop terminate within a while.Can any give me solution to this
How can you even compile your code (there are a lot of errors)? The following one works properly
#include <windows.h>
class SimpleThread
{static DWORD WINAPI ThreadFunc(LPVOID p)
{
while(1)
{
printf("Test");}
}
public:
void SimpleThread::Start()
{
DWORD dwThreadId, dwThrdParam = 1;
HANDLE threadHandle;
threadHandle = CreateThread(
NULL,
0,
ThreadFunc,
&dwThrdParam,
0,
&dwThreadId);
}
};void main()
{
SimpleThread t;
t.Start();
while (1);
}:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]