Reputation: 49
I am trying to write a threaded application in Delphi 2010 using Indy. Both of these are new to me and I am struggling with synchronising the Vcl. I have read about synchronising with the Vcl, using Critical Sections, TThread.Synchronize, TIdNotify etc. I would like to see an example of how to use TIdnotify. In my case I am trying to update a TreeView from a thread. I have searched the groups/forums, but no success. Any examples would be very much appreciated. TIA
Upvotes: 2
Views: 2590
Reputation: 2660
type
TMyNotify = class(TidNotify)
private
FMyData: string;
protected
procedure DoNotify; override;
end;
procedure TMyNotify.DoNotify;
begin
FormMain.TreeView1.Items.Add(nil, FMyData);
end;
And in your Thread:
var
MyNotify: TMyNotify;
begin
MyNotify := TMyNotify.Create;
MyNotify.FMyData := 'A new node';
MyNotify.Notify;
Upvotes: 9