Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- procedure Test(Sender: TObject);
- begin
- WriteLn('>>> ', GetTimeRunning());
- end;
- procedure TTimer.Setup();
- begin
- Self.Init(nil);
- Self.SetOnTimer(@Test);
- Self.SetInterval(100);
- Self.SetEnabled(True);
- end;
- procedure TTimer.__Toggle();
- begin
- self.SetEnabled(not self.GetEnabled());
- end;
- function TTimer.Toggle(): Boolean;
- begin
- Sync(@Self.__Toggle);
- Result := Self.GetEnabled();
- end;
- var
- t: TTimer;
- begin
- sync(@t.Setup);
- for 0 to 10 do
- begin
- Sleep(500);
- WriteLn t.Toggle();
- Sleep(500);
- WriteLn t.Toggle();
- end;
- t.Free();
- end.
Add Comment
Please, Sign In to add comment