Link to home
Start Free TrialLog in
Avatar of vassim
vassim

asked on

Threads in Cpp.NET

I have got a code sample off of the MSDN at this address

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__beginthread.2c_._beginthreadex.asp

All I want is to create a thread that waits for a key-stroke to terminate a while loop,
The sample above does exactly that and works when I run it on its own workspace, but when I try to place it into my own project, it doesnt event compile, here is what my code looks like:

void CheckKey( void *dummy );
BOOL repeat = TRUE;

void main(void)
{
       ......
       ......
       _beginthread(CheckKey, 0, NULL);
       while(repeat)
       {
              ......
              ......
       }
}
//seperate thread that waits for a key-stroke
void CheckKey( void *dummy )
{
       _getch();
       repeat = 0;    /* _endthread implied */
}  


But then I get this error:

error C3861: '_beginthread': identifier not found, even with argument-dependent lookup

I have included process.h in the project so I dont think Im missing the header file.
 
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vassim
vassim

ASKER

Its Ok now, I compared the project properties and I found in "Check for 64 bit portability issues" If I change to "No" then it works. I dont know why, but it works and thats the main thing.
BTW had a read of that article and it explained quite a few things about threads, very good for a novice like myself,
Thanks.