Board index » cppbuilder » Cancel button
Claude Tadonki
![]() CBuilder Developer |
Claude Tadonki
![]() CBuilder Developer |
Cancel button2005-05-06 02:23:22 AM cppbuilder9 Hello, I am looking for a way to put a cancel button in my application so that when it runs, the user can click on the cancel button (anytime) to stop the process. Thanks. Regards, Claude |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2005-05-06 03:51:01 AM
Re:Cancel button
"Claude Tadonki" < XXXX@XXXXX.COM >wrote in message
QuoteI am looking for a way to put a cancel button in my application 1) have a variable somewhere that both your button and your process can access. Have the button set the variable value, and have the process check the value periodically. Assuming your process is running in the main thread, it will also have to call Application->ProcessMessages() before checking the variable value, so that the button click has a change to be processed. 2) move the process code into a worker thread. Then the button can simple terminate the thread when clicked. Gambit |
Rob
![]() CBuilder Developer |
2005-05-06 08:02:06 PM
Re:Cancel button
Remy Lebeau (TeamB) wrote:
Quote
TerminateThread(), for example, is not a good way to kill a thread: it prevents certain resources used by the thread from being cleaned up. That does not go down well for most programs, particularly long running ones. {smallsort} |