alr1976 0 Posted April 26, 2019 Hi! I Need to run a task each 1 second but i Need to pass a variable First Time. It Is possible? How ? Can you do male a small example? Thanks PS i buy your last book. Next week i Will riceive It. Share this post Link to post
Primož Gabrijelčič 223 Posted April 26, 2019 FWorker := TWorker.Create(SpinEdit1.Value); FTimedTask := Parallel.TimedTask .Every(1000) .Execute( procedure (const task: IOmniTask) var value: integer; begin FWorker.Tick; value := FWorker.Value; task.Invoke( procedure begin ListBox1.Items.Add(value.ToString); end); end); FTimedTask.Start; type TWorker = class strict private FValue: integer; public constructor Create(startAt: integer); procedure Tick; property Value: integer read FValue; end; constructor TWorker.Create(startAt: integer); begin inherited Create; FValue := startAt; end; procedure TWorker.Tick; begin Inc(FValue); end; Source: https://gist.github.com/gabr42/15a514a2960be43a0a5b1a6db69274f7 2 Share this post Link to post