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 


checking if something has been done in an amount of time

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Jul 21, 2008 10:56 am    Post subject: checking if something has been done in an amount of time Reply with quote

Is there anyway to check if something has been done in a certain amount of time? I can really only think of creating one thread that executes a function and another thread that just sleeps, and if the other thread isn't finished in the amount of time it should (the other thread exits before it does) the function being executed in the thread returns an error. Of course, since this has to be done simultaneously, it would have to be done with multi-threading, but that doesn't work if you only have one processor, so how can I do this? Thank you for your comments.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Jul 21, 2008 11:02 am    Post subject: Reply with quote

One processor CAN multithread, but not just in parallel. Just make two threads and keep checking from another one if the other thread is done and if time runs out, do whatever you want to.
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Jul 21, 2008 11:07 am    Post subject: Reply with quote

Well, I guess it can, but it's not exactly multi-threading. It's more switching between each so incredibly fast you can't even tell.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Mon Jul 21, 2008 12:33 pm    Post subject: Reply with quote

Depends on what you're actually looking for. Search for WaitForSingleObject()
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Mon Jul 21, 2008 12:35 pm    Post subject: Reply with quote

:O Totally forgot about WaitForSingleObject.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Mon Jul 21, 2008 1:14 pm    Post subject: Reply with quote

What about GetTickCount?
Back to top
View user's profile Send private message MSN Messenger
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Tue Jul 22, 2008 6:22 am    Post subject: Reply with quote

Jani wrote:
One processor CAN multithread, but not just in parallel. Just make two threads and keep checking from another one if the other thread is done and if time runs out, do whatever you want to.


That would cause deadlock. EX: Thread 1 waits for Thread 2 to terminate. Thread 2 can't terminate cause it's waiting for Thread 1 to terminate. Both threads are in a suspended state and your program freezes.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Jul 22, 2008 7:26 am    Post subject: Reply with quote

rapion124 wrote:
EX: Thread 1 waits for Thread 2 to terminate. Thread 2 can't terminate cause it's waiting for Thread 1 to terminate.
I didn't say T1 would wait T2 and vice versa, did I? -_- I mean that T1 waits untill T2 is done, or if time runs out at T1, it just kills T2, or something -> no deadlocks.
Back to top
View user's profile Send private message
Ksbunker
Advanced Cheater
Reputation: 0

Joined: 18 Oct 2006
Posts: 88

PostPosted: Tue Jul 22, 2008 9:37 am    Post subject: re: Reply with quote

pseudo...

Code:
expected = 1000 ; ms
Start =  GetTickCount()
  ; do what you want
End = GetTickCount()
Elasped = End - Start
COMPARE elasped vs. expected
if bigger... too long
if smaller... good
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