Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdSync vs TThread.Synchronize
#2
(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.

Reply


Messages In This Thread
TIdSync vs TThread.Synchronize - by happyzj - 02-19-2021, 08:08 AM
RE: TIdSync vs TThread.Synchronize - by rlebeau - 02-19-2021, 04:08 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)