I have to develop a program to keep watching values in databases based on a Select statement given by me
the watched values can be changed at anytime and my program must sense the changes based on a result of the select statement which is given by me
i want to watch the select result by using TThread because my system is also has another features and the user need to work on it not only to watch values.
how to do it using TThread in Delphi XE2
am using VCL…no .Net
Regards.
[Edit]
Improved answer, now thread runs continuously and “keep watching values”.
Let’s build a sample.
First, Create new VCL app. Drop on the form one TListBox and two TButton component. You need to write button click handlers and add one private method. Entire unit should look like this:
Next we should add our thread, select from menu: File -> New unit and replace with code:
unit Unit2;
Now, when you press Button1, you will receive from thread Items in your combo. Pressing Button2 thread stops executing.
You should take in account:
Set Interval to watch values, default is 1000ms, see interval property;
All your code (include DB access components) inside Execute and related to it should be thread-save.