Delphi IDE (89)
Windows with Delphi (280)
About this site
Links to us
This article has not been rated yet. After reading, feel free to leave comments and rate it.
I am writing a procedure, which may take a long time to execute. I want
the user to be able to stop it at any point of execution. I can use
Application.ProcessMessages to handle a click of the 'STOP' button.
I also thougt about creating a new thread for the procedure.
In either case I have to check for a variable 'ProcedureStopped' (with
Application.ProcessMessages) or I have to check for MyThread.Terminated.
Both of these require frequent polling. I'd prefer some kind of
interrupt to exit the procedure.
By Hallvard Vassbotn, firstname.lastname@example.org :
Unfortunately, by default the VCL does not have a very thread-friendly
mainthread message loop. It is possible to override the message loop by
hooking Application.OnIdle and call MsgWaitForMultipleObjects there.
Doing this you can build your own multithread aware message loop and
thus easiliy get notified of events and other signals raised from