Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] CreateThread doesn't work?!?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 01, 2009 4:19 am    Post subject: [C++] CreateThread doesn't work?!? Reply with quote

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
View user's profile Send private message
Cheat Engine User
Something epic
Ban
Reputation: 60

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Wed Jul 01, 2009 4:47 am    Post subject: Reply with quote

Maybe the first parameter needs to be NULL?
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 01, 2009 4:54 am    Post subject: Reply with quote

it is NULL Surprised
NULL = 0
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed Jul 01, 2009 4:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 01, 2009 5:01 am    Post subject: Reply with quote

oh right i can't believe i haven't noticed it XDDDDD
thanks
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Wed Jul 01, 2009 5:02 am    Post subject: Reply with quote

nvm
_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Wed Jul 01, 2009 5:03 am    Post subject: Reply with quote

Pro-surf
it was because i exit the program right after creating the thread
now it works great thanks Very Happy
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Wed Jul 01, 2009 5:05 am    Post subject: Reply with quote

np.

<hint>Now we could talk about using Sleep in a threaded program...</hint>
Back to top
View user's profile Send private message
Pro-surf
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2007
Posts: 1415
Location: Under Ur Bed , Moauahauha

PostPosted: Wed Jul 01, 2009 5:05 am    Post subject: Reply with quote

thats why i said nvm .. lol
_________________
ProsTrain VIP |..........| - 80% Done Smile im close to the finish line Smile
Back to top
View user's profile Send private message
jackyyll
Expert Cheater
Reputation: 0

Joined: 28 Jan 2008
Posts: 143
Location: here

PostPosted: Wed Jul 01, 2009 9:22 pm    Post subject: Reply with quote

Jani wrote:
np.

<hint>Now we could talk about using Sleep in a threaded program...</hint>


Please do Smile
Back to top
View user's profile Send private message AIM Address MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Sun Jul 05, 2009 9:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites