CMB
CMB

Reputation: 49

How to use TIdNotify

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

Answers (1)

Arjen van der Spek
Arjen van der Spek

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

Related Questions