pr2501
asked on
How to see TTimer interval
count down in TEdit?
ASKER
If i set timer interval to 10000 ms. On timer event after 10 s specific code will be executed.
A need to know how much time i have less until timer time will be elapsed.
A need to know how much time i have less until timer time will be elapsed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, thank you.
Can You explain me just another thing.
Will timer event on interval interrupt another task which was running at that moment.
And the task will continue after timer code will be executed?
Can You explain me just another thing.
Will timer event on interval interrupt another task which was running at that moment.
And the task will continue after timer code will be executed?
>> Will timer event on interval interrupt another task which was running at that moment.
No, whatever you have in the Timer event will run concurrently with the other code that you might have.
For example if you have ListBox, Button and Timer on a form: The Timer running as per the above code and you have pressed a button that has the following code:
No, whatever you have in the Timer event will run concurrently with the other code that you might have.
For example if you have ListBox, Button and Timer on a form: The Timer running as per the above code and you have pressed a button that has the following code:
procedure TForm1.Button1Click(Sender: TObject);
var
j:integer;
begin
for j := 1 to 30000 do
begin
ListBox1.Items.Add(inttostr(j));
ListBox1.Selected[ListBox1.Items.Count-1] := true;
Application.ProcessMessages;
end;
end;
Then you get the Timer count down while the ListBox adds the loop counter.
ASKER
Thank you very much
ASKER
Try next code with two TListbox, TButon and TTimer.
They are not ruining together?
They are not ruining together?
procedure TForm4.Button1Click(Sender: TObject);
var
j:integer;
begin
//timer1.Enabled:=false;
for j := 1 to 30000 do
begin
ListBox1.Items.Add(inttostr(j));
ListBox1.Selected[ListBox1.Items.Count-1] := true;
Application.ProcessMessages;
end;
end;
procedure TForm4.Timer1Timer(Sender: TObject);
var
k:integer;
begin
for k := 1 to 30000 do
begin
ListBox2.Items.Add(inttostr(k));
ListBox2.Selected[ListBox2.Items.Count-1] := true;
Application.ProcessMessages;
end;
end;
ASKER
pleas use also in attached code below:
timer1.Enabled:=false;
timer1.Enabled:=false;
procedure TForm4.Timer1Timer(Sender: TObject);
var
k:integer;
begin
timer1.Enabled:=false;
for k := 1 to 30000 do
begin
ListBox2.Items.Add(inttostr(k));
ListBox2.Selected[ListBox2.Items.Count-1] := true;
Application.ProcessMessages;
end;
end;
end.
not really the way to go, and especially not with application.processmessage s
the article i wrote about the progressbar and a thread should be a lot better than this
the article i wrote about the progressbar and a thread should be a lot better than this
I should have been more clear on my answer about the concurrent processing through the Timer.
Timer can work concurrently (as i shown in my last post) but it can not work like threads. Timer can accomplish Background Processing or Multitasking but it can not perform Multithreading.
Timer can work concurrently (as i shown in my last post) but it can not work like threads. Timer can accomplish Background Processing or Multitasking but it can not perform Multithreading.
ASKER
I understand.
Now is not necsessary for me to study Multithreading.
(But sill it would be of help if i could see how much time remains of timer time in TEdit
(like count down).)
Thank you
Now is not necsessary for me to study Multithreading.
(But sill it would be of help if i could see how much time remains of timer time in TEdit
(like count down).)
Thank you
If you set the timer interval to 1000 ms (1 second) then:
Open in new window
For counting down:
Open in new window