Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Mar : Re: OnWork event handler not triggered ?...
| Subject: | Re: OnWork event handler not triggered ?... |
| Posted by: | "Don" (blacknapk..@twistandfruge.com) |
| Date: | Fri, 3 Mar 2006 00:43:37 |
> In a quite big project I used TIdTCPClient.OnWork event handler
> to update a progress bar.
> I discovered why my event was never called. In the following function :
> procedure TIdComponent.DoWork(AWorkMode: TWorkMode; const ACount: Int64);
> procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
> var
> S: TFileStream;
> begin
> S := TFileStream.Create('D:\test', fmCreate);
> try
> AContext.Connection.IOHandler.ReadStream(S);
> finally
> S.Free;
> end;
Your detective work is good... but your conclusion is a wee bit off.
Your OnWork event is not being avoided because of an invalid work count. The
OnWork event is never being triggered by ReadStream at all.
The problem actually lies in the IOHandler.ReadStream method. It calls
BeginWork and EndWork... but never calls DoWork when it reads any of the
buffer-sized chunks of data.
Until a couple of weeks ago, the Write(TIdStream) method had the same issue.
I'll pass the info along to the Indy Core team.
Thanks very much for the report... and the detective work. <g