Hi,
I'm facing some problems using TMSFMXPlanner with threads. In order to keep my application responsive, during data load process, i do something like this:
procedure TForm1.RefreshSchedule(aClubId: integer);
begin
TTask.Run(procedure
begin
try
try
TThread.Synchronize(nil,
procedure
begin
StartCursor;
end);
GetAllSchClas(aClubId); //load data from database
LoadTMSFMXPlanner1; //load TMSFMXPlanner1
except
on E: Exception do
begin
TThread.Synchronize(nil,
procedure
begin
ShowMessage(E.Message);
end);
end
end;
finally
TThread.Synchronize(nil,
procedure
begin
StopCursor;
end);
end;
end);
end;
On the first execution, the code runs without problems, but if I reload planner, i getting an access violation on FMX.TMSPlanner :
procedure TTMSFMXCustomPlanner.DrawDisplay(ADisplay: TTMSFMXPlannerDisplayList);
Can someone help me with this please?
Thanks
What Delphi version do you use and what operating system do you target?
Hi
Sorry, windows 7, 8, 10 (later IOS and android) and delphi Berlin
thanks
Hi,
Hi,
Thank you for the reply. I reviewed my code, and made some changes. In fact I was not call the LoadTMSFMXPlanner1 in the correct way... Now, LoadTMSFMXPlanner1 is call in a sync block:
TThread.Synchronize(nil,
procedure
begin
try
TMSFMXPlanner1.Enabled := false;
//load TMSFMXPlanner1
LoadTMSFMXPlanner1;
finally
TMSFMXPlanner1.Enabled := true;
end;
end);
This solves my problem, but now I have a new one... I need to disable TMSFMXPlanner1 in order to avoid user interaction during load process. After the TMSFMXPlanner1 became active, the items appears to be disabled, if i maximize the form the items get drawn correctly. I alredy try to call TMSFMXPlanner1.Repaint but it dosen't solve the problem. Is there another way of doing this?
Thanks!
You can set TMSFMXPlanner1.HitTest := False to disable interaction. You can also wrap the planner with TMSFMXPlanner1.BeginUpdate; TMSFMXPlanner1.EndUpdate;
Hi,
I'm already using BeginUpdate and EndUpdate. With the HitTest instead off Enabled the problem it's solved.
Thanks for the tip