Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Long Process Interruption
I'm writing a complicated process program and am not sure how to implement a user interrupt mechanism.
This is a long process, so I have a form that will display status messages. After the needed setup, there's a READ EVENTS command. Then, the form has a "Start Process" button to get things going. Once started, the legend changes to "Cancel" and it's Cancel property set to .T. (so that Esc will activate it).
There is a global variable, bAborted, that the process code periodically checks so that it "knows" it must terminate. The Cancel button is set to change this to .T. When stepping thru the code, this works fine.
But, during normal running, it doesn't work; clicking the button and pressing Escape (SET ESCAPE is OFF) don't stop the process at all. Apparently, there's no time to service the button's Click() method as the process program is running at full tilt.
To solve this, I periodically issue an INKEY(1) command (and look for an Esc keypress that will also set the variable). This works. However, I can't help but think that there must be a better way to do this.
Can anyone offer suggestions?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement