Delphi Pause Program

Posted on by
Delphi Pause Program Average ratng: 5,8/10 9185votes

Yes, yes, I know, it's Delphi, but that's just how it is. Anyway, I've got an algorithm.

I'm new to Delphi, and I've been trying to find something in the help file that explains how to make a program pause temporarily. The timer component seems a likely. I can ot remember how to pause a procedure for a certain amount of seconds, say 3 secounds and then I want it to keep running. Board index » delphi » 'pause' Scott Earne. Delphi Developer. Wed, 18 Jun 1902 08:00:00 GMT. It changes the way the program writes to the screen.

I'd like to pause it at some point and then continue once the user presses a button. How do I do that? I've browsed the documentation, and searched the internet, but no luck yet. If anyone is wondering, I'm making a program to illustrate how various sorting algorithms work, by drawing little colored bars and moving them around (see the Wikipedia page on Quicksort for my inspiration). Obviously, being able to 'step' will help a lot with understanding. Here's the relevant code snip.

There are a few options. Carnildo's will work, but busy loops are rarely a good idea. You're going to be chewing up the CPU waiting for the flag to change. One option is to do a similar thing, but with multithreading.

Games Russian Patch here. If the algorithm you're trying to pause is in a different thread to the main event loop, then you can block the thread on a semaphore or a mutex or similar (whatever the language has available), then have the main event thread signal it when the button is clicked. This has the advantage that usually semaphores and mutexes are provided by the OS. So blocking on them will send your process idle, instead of busy-looping. It has the disadvantage that you need to use threading, with all the cons that it brings. Another option (under Windows at least, I haven't done any GUI programming on other platforms, but I presume a similar option is there), you can pop up a modal dialog box. Processing will halt until the dialog is closed.

See More On StackoverflowDelphi Pause Program

Comments are closed.