Wie versprochen mein Beispiel Code:
Delphi-Quellcode:
procedure Test;
begin
MyThreadCriticalSection.Enter;
Try
inc( Counter );
while not (qbytes= 1000) do
begin
Application.ProcessMessages;
inc(qbytes);
Sleep(1);
end;
Finally
qbytes:=0;
MyThreadCriticalSection.Leave;
End;
Unit1.Form1.Label1.Caption:=IntToStr(Counter);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
merkeEnabled:Boolean;
begin
merkeEnabled:=Timer1.Enabled;
Timer1.Enabled:=false;
Test;
Timer1.Enabled:=merkeEnabled;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Test;
end;