PDA

View Full Version : Thread calling convention



Sebastiani
05-28-2002, 09:57 AM
Having have a little problem where I can call a thread- creation function in a procedural program but not from within a class?






#include <include.h>
#include <windows.h>


THREADFUNC foo(char* buff )
{
int len = strlen(buff);
int i, j;
for(j = 0; j < 3; j++)
{
for(i = 0; i < len; i++)
{
PrintCtr("Buff[%i]: %c", i, buff[i]);
}
Sleep(1000);
}
}








int main()
{

char b[] = "One";
char c[] = "Two";

THREAD t = NULL;
THREAD v = NULL;



halt();

t = NewThread( foo, b );
v = NewThread( foo, c );



while(ThreadIsActive(t) && ThreadIsActive(v) ); //...wait...


CloseHandle(t);
CloseHandle(v);



return 0;
}

ygfperson
05-28-2002, 07:50 PM
wouldn't this go under the c++ board?