| View previous topic :: View next topic |
| Author |
Message |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 01, 2009 4:19 am Post subject: [C++] CreateThread doesn't work?!? |
|
|
How come when i want to create a thread in console application it's not working
but when i'm building GUI (creating empty project and create the whole window by myself) it works?!
the code goes like
| Code: |
void someThread ()
{
for (int i = 0; i < 100; i ++){
_tprintf_s(__TEXT("asd\n"));
Sleep(100);
}
}
int main (void)
{
CreateThread(0,0,(LPTHREAD_START_ROUTINE)&someThread,0,0,0);
return 0;
}
|
|
|
| Back to top |
|
 |
Cheat Engine User Something epic
Reputation: 60
Joined: 22 Jun 2007 Posts: 2071
|
Posted: Wed Jul 01, 2009 4:47 am Post subject: |
|
|
| Maybe the first parameter needs to be NULL?
|
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 01, 2009 4:54 am Post subject: |
|
|
it is NULL
NULL = 0
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Jul 01, 2009 4:56 am Post subject: |
|
|
How about you read some stuff about threads? Obliviously the main thread is reaching its end before the other thread has done anything. It's better to know what are you doing than just copy pasting code...
EDIT: Stupid srikethru doesn't work :(
Last edited by Jani on Wed Jul 01, 2009 5:03 am; edited 2 times in total |
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 01, 2009 5:01 am Post subject: |
|
|
oh right i can't believe i haven't noticed it XDDDDD
thanks
|
|
| Back to top |
|
 |
Pro-surf Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Dec 2007 Posts: 1415 Location: Under Ur Bed , Moauahauha
|
Posted: Wed Jul 01, 2009 5:02 am Post subject: |
|
|
nvm
_________________
ProsTrain VIP |..........| - 80% Done im close to the finish line
 |
|
| Back to top |
|
 |
Stylo Grandmaster Cheater Supreme
Reputation: 3
Joined: 16 May 2007 Posts: 1073 Location: Israel
|
Posted: Wed Jul 01, 2009 5:03 am Post subject: |
|
|
Pro-surf
it was because i exit the program right after creating the thread
now it works great thanks
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Jul 01, 2009 5:05 am Post subject: |
|
|
np.
<hint>Now we could talk about using Sleep in a threaded program...</hint>
|
|
| Back to top |
|
 |
Pro-surf Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Dec 2007 Posts: 1415 Location: Under Ur Bed , Moauahauha
|
Posted: Wed Jul 01, 2009 5:05 am Post subject: |
|
|
thats why i said nvm .. lol
_________________
ProsTrain VIP |..........| - 80% Done im close to the finish line
 |
|
| Back to top |
|
 |
jackyyll Expert Cheater
Reputation: 0
Joined: 28 Jan 2008 Posts: 143 Location: here
|
Posted: Wed Jul 01, 2009 9:22 pm Post subject: |
|
|
| Jani wrote: | np.
<hint>Now we could talk about using Sleep in a threaded program...</hint> |
Please do
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sun Jul 05, 2009 9:07 pm Post subject: |
|
|
| What. Why sleep? It'll just close everything after the sleep period is over. Just put a conditional loop in the main thread.
|
|
| Back to top |
|
 |
|