(02-19-2021, 08:08 AM)happyzj Wrote: Hi, just wondering: does TIdSync nowadays still work in the latest Indy version?
Yes, it is still fully implemented. As is TIdNotify.
(02-19-2021, 08:08 AM)happyzj Wrote: I see a warning saying it is deprecated and suggest to change to use TTThread.Synchronize
Only in versions of Delphi/C++Builder/FreePascal that support the public TThread.Synchronize() that takes an anonymous procedure as input.
(02-19-2021, 08:08 AM)happyzj Wrote: however in and old "indy indepth" doc, it introduces TIdSync as following
That doc is OLD, it predates a lot of changes to Indy's internals.
(02-19-2021, 08:08 AM)happyzj Wrote: I use TIdsync a lot with passed in paramteres and return value (mainly to read property value of a UI component on the main form).
Now, if I switch to use TTThread.Synchronize, is it really as easy as using TIdsync to allow pass parmater to and get return value?
It is easier, using an anonymous procedure, for example:
Code:
var TheResult: TheType;
TThread.Synchronize(nil,
procedure
begin
TheResult := DoSomethingWith(parameters);
end
);
(02-19-2021, 08:08 AM)happyzj Wrote: And if I keep the code as is (using TIdsync), what would be a potential risk of this in future considering it is now "deprecated"?
It will not be removed in Indy 10, but it will likely be removed in Indy 11 with other deprecated features, whenever that eventually gets released.