TacThread component
Hierarchy Properties Methods Events |
The acThread component is enhancement of standard invisible TThread class. Extremely easy to use, since you can specify properties and events directly in Object Inspector as in any usual component, and contains much more features.
|
For example, you need to run process which will take a lot of time to be completed. This can be anything, sorting big arrays, copying, searching or downloading the data and so forth
Anything that will take rather much time but should not stop and even slow down user interface and other processes
|
|
Well, simply drop the acThread component onto your form and specify all actions of this thread in the OnExecute event handler. To execute thread call Execute method. To terminate call Terminate. If you wish to suspend thread temporary, without total termination use Suspended property (set it to True to suspend and to False to resume thread), or Suspend/Resume methods.
|
|
If your thread needs to send output to the main VCL thread, or just make some specific actions in your forms (i.e: fill the list view or increase position of the progress bar), you must synchronize actions between different threads to avoid multi-thread conflicts. To synchronize threads and complete some operations in main VCL thread use Synchronize method.
|
|
To change scheduling priority of thread use Priority property. To be notified when thread terminated write it to the OnTerminate event handler
|
You can download the example which demonstrates how to use acThread component from http://www.appcontrols.com/demos/threaddemo.zip, or compiled executable from http://www.appcontrols.com/demos/exe/ThreadDemo.exe.
|
acSQLQueryThread, acHTTP and acAutoUpgrader.
|