Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pausing without using CPU power or blocking application

Posted on 2004-04-11
2
Medium Priority
?
248 Views
Last Modified: 2010-04-04
Hi,

last question, then mi application is finished! ;-)

Is there a possibility to pause my application without using a lot of CPU power or blocking it from taking any new commands?

When I use "sleep()", my application is blocked and doesn't take any new commands.

And with:

procedure TForm1.pause(time1: longword);
var time2 : longword;
begin
      time2 := GetTickCount;
      repeat
                Application.ProcessMessages;
      until (GetTickCount - time2 > time1);
end;

CPU usage raises to 100% immediately. This is not very usefull, because I have a thread which is waiting for CPU usage to fall below a specific percentage...

Any other ideas? thanks
0
Comment
Question by:Bohne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
rbohac earned 200 total points
ID: 10800596
you are on the right track. Combine Application.ProcessMessages with a 1ms sleep

procedure pause(Seconds:Cardinal);
var StartTime:Cardinal;
begin
     StartTime := GetTickCount;
     Seconds   := Seconds * 1000;
     repeat
               Application.ProcessMessages;
               sleep(1);
     until (GetTickCount > (StartTime + Seconds));
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Pause(5);
  ShowMessage('Hello');
end;
0
 
LVL 17

Expert Comment

by:mokule
ID: 10801135
I don't know the nature of Your pause but maybe the use of TTimer would be good solution.

It is also important what time periods do You need.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question