Solved

Stopping Processing...

Posted on 1998-10-05
3
126 Views
Last Modified: 2010-04-06
Hi..
  I wish to have a 'Stop' or 'cancel' button in my application such that when clicked by the user in the middle of a processing job, the app will cease processing and return to the ready state. How can I do this?

Cheers
   Shawn Halfpenny
0
Comment
Question by:aztec
3 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1341820
And what state is that??? Give some sample codes or something similar...

Regards,
Viktor Ivanov
0
 

Accepted Solution

by:
gdebiasa earned 50 total points
ID: 1341821
You'll have to put Application.ProcessMessages throughout the process you want to have interrupted. Then, you'll be able to receive an event (like the button click), and set a boolean (StopNow := true, for example).

Then, (I presume you're looping over something, or a similar operation), at the top of the loop, check StopNow and exit the loop/procedure (using break or exit).

The major problem with this is that Application.ProcessMessages will greatly slow down whatever process you're performing (I wouldn't use it more than once per loop, but you might need more, depending on exactly what's happening in your process).

Hope this helps,
Glen
0
 

Author Comment

by:aztec
ID: 1341822
Thanks Glen!

Shawn
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

828 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