Avatar of IT79637
IT79637Flag for United States of America

asked on 

Is there a way to pause a program?

Is there a way to pause a program?  After the program is paused, an event, such as  clicking a button would resume execution with the Button event.

Thanks.
Delphi

Avatar of undefined
Last Comment
Geert G
Avatar of SteveBay
SteveBay
Flag of United States of America image

What's wrong with a modal dialog like ShowMessage(''); ?
ASKER CERTIFIED SOLUTION
Avatar of SteveBay
SteveBay
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of 2266180
2266180
Flag of United States of America image

you will want to place a sleep(10) in that while there otherwise the cpu will go nuts.

Avatar of SteveBay
SteveBay
Flag of United States of America image

Good point cuily! I was just riffing :p
Avatar of Johnjces
Johnjces
Flag of United States of America image

I like a delay or pause.... keeps windows messages happening but delays or pauses the program... like sleep.

I know there may be some contention about this, but I use it a lot and have never had an issue.

Procedure Delay(MSecs: Cardinal);
var
 FirstTick, CurrentTick : Cardinal;
 Done : Boolean;
begin
 Done := FALSE;
 FirstTick := GetTickCount;
 While Not Done do
  begin
   Application.ProcessMessages;
   CurrentTick := GetTickCount;
   If Int64(CurrentTick) - Int64(FirstTick) < 0 Then
    begin
     If CurrentTick >= (Int64(FirstTick) - High(Cardinal) + MSecs) Then
      Done := TRUE;
       End
        Else
         If CurrentTick - FirstTick >= MSecs Then
          Done := TRUE;
  end;
end;

usage:

delay(1000);
button1.click;


John
Avatar of Geert G
Geert G
Flag of Belgium image

if it's a thread you want to pause ...

thread.Suspend;
pauses it

thread.Resume;
restarts it

off course can't be done with the main thread otherwise there is no more way of reacting on a button pressed to resume
Delphi
Delphi

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

60K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo