thread TauThread component
Properties Methods Events
Return to Introduction  Previous page  Next page
Overview
The auThread 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.  

How to use ?
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 auThread 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  

Sample code
You can download the example which demonstrates how to use auThread component from http://www.appcontrols.com/demos/threaddemo.zip, or compiled executable from http://www.appcontrols.com/demos/exe/ThreadDemo.exe.  

See also other components with built-in auThread component:
auHTTP and auAutoUpgrader.