| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Aug 13, 2008 2:51 pm Post subject: [Delphi] Looping |
|
|
Edit2: The thing on the web didn't really work.
Ok so I am program a dll in delphi. (To Inject into another process)
I am process information with a huge loop. How do I prevent the host application from freezing because of the loop?
The example I found on the web said use
Application.ProcessMessages;
But it didn't work. My app still froze.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 13, 2008 3:34 pm Post subject: |
|
|
create the loop in a new thread?
_________________
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed Aug 13, 2008 3:48 pm Post subject: |
|
|
If you're injecting a DLL, it would automatically create a new thread for your program to run in and it shouldn't affect the host at all. Post the code so we can see what's wrong.
Also, I'm not entirely sure how a delphi DL will interact with a program written in a nother language. Might work fine, but I have no idea.
_________________
|
|
| Back to top |
|
 |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Wed Aug 13, 2008 4:44 pm Post subject: |
|
|
avoid using "repeat"
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Aug 13, 2008 4:46 pm Post subject: |
|
|
IM not using repeat.
Here:
While 1=1 do
begin
//my script here
end;
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed Aug 13, 2008 5:11 pm Post subject: |
|
|
You're probably fucking something up with your script.
_________________
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Wed Aug 13, 2008 5:13 pm Post subject: |
|
|
| dnsi0 wrote: | IM not using repeat.
Here:
While 1=1 do
begin
//my script here
end; |
Why... use.... a.... loop.... inside.... a.... dll..... ? (Unless you're checking for key state)
@In Delphi you don't have to use CreateThread (BeginThread wrapper) in order to inject and modify crap.
look here - http://rot1blg.wordpress.com/2008/05/08/coding-a-win32-console-trainer-for-ms-minesweeper/
scroll down a bit.
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 13, 2008 5:17 pm Post subject: |
|
|
You have to call sleep for at least 10 miliseconds
Same thing in C or any language.
And rot1, sometimes you have to constantly change a value...What do you think CEF's freeze state does? It just constantly changes the value using a loop
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Wed Aug 13, 2008 5:22 pm Post subject: |
|
|
| I did sleep(100);
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Wed Aug 13, 2008 6:57 pm Post subject: |
|
|
100 might be too much if your loop is completely empty I'd go with something like 10 or so.. just to keep the CPU usage down to 0-1%.
100 is like 10 times per second it will create some kind of lag.. but it wont freeze up application so I don't know
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Wed Aug 13, 2008 7:13 pm Post subject: |
|
|
Do you have any idea what you just said? 100 milliseconds is more than 10 ms so the loop will be run less times per second.
_________________
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Wed Aug 13, 2008 7:17 pm Post subject: |
|
|
^
|
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Wed Aug 13, 2008 7:20 pm Post subject: |
|
|
Your loop design fails.
| Code: |
while 1=1 do
begin
//This always evaluates to true so thread gets "locked" processing this
//You can add a 'break' to get the loop to stop
end;
|
A much better design would be a for-loop, or a while/repeat by testing something that is not always true.
|
|
| Back to top |
|
 |
HalfPrime Grandmaster Cheater
Reputation: 0
Joined: 12 Mar 2008 Posts: 532 Location: Right there...On your monitor
|
Posted: Wed Aug 13, 2008 7:23 pm Post subject: |
|
|
Sleep(10) sleeps for 10 ms, 100 loops per sec
Sleep(100) sleeps for 100 ms, 10 loops per sec.
_________________
|
|
| Back to top |
|
 |
|