Stopwatch of Idle Time

Asked

Viewed 102 times

0

I have a Label component that shows the number of files in a folder.

While downloading multiple files the number displayed by Tlabel changes (as the files in the folder).

How do I stop when label caption stops changing (or stops displaying different values) to fire a stopwatch from scratch?

For a simple stopwatch use the following code:

procedure TFrmMain.TimerAtivTimer(Sender: TObject);
begin
//Cronometro para Tempo em Atividade
LblTempoAtividade.Caption := 'Em Atividade:   ' + FormatDateTime('hh:mm:ss', TempoAntigo - NOW);
Application.ProcessMessages;

It would take a new Timer for that?

1 answer

0


In Tfrmmain, declare a variable (initialize it with 0):

private TempoAntigo: TTime; ...

When you receive a new file, update the variable:

procedure TFrmMain.TimerAtivTimer(Sender: TObject); begin if novo_arquivo_na_pasta then begin LblTempoAtividade.Caption := 'Em Atividade: ' + FormatDateTime('hh:mm:ss', now - TempoAntigo); TempoAntigo := now; end; ... end;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.