-
Book Overview & Buying
-
Table Of Contents
Delphi High Performance - Second Edition
By :
The last parallel pattern I will cover in this book is a simple timer that executes in a background thread. It can be configured very similarly to Delphi’s TTimer and is extremely easy to use.
The ParallelTimedTask demo tests the network connection by executing an HTTP GET every 10 seconds and then displaying the results of the operation on the form. To prevent any blocking, it executes the network operation in a background thread. The interface of the program is shown in the following screenshot:
Figure 10.7 – The ParallelTimedTask demo in action
The code uses Parallel.TimedTask factory, which returns an IOmniTimedTask interface that is stored in the FTimedTask form field. To simplify the operation, everything is set up in the form’s OnCreate event, as shown here:
procedure TfrmTimedTask.FormCreate(Sender: TObject); begin FTimedTask := Parallel.TimedTask ...