开发者

indy GET dowloading speed

Welcome,

I have to create caption with information about downloading speed in my application using indy http get compontent.

In my mind i found simple solution.

At onwork event i will get actual progress of downloading (size) and compare it with previous reading. (for example every 5 seconds). curent size minus previous (5 seconds eariel, stored in global var) divide by 5 seconds * 8 and i will get speed. If actual size is equal开发者_开发百科 previous then sped is always 0.

So i want start codding, but i found problem in simple function called odwork.

procedure TForm1.HttpWork(ASender: TObject; AWorkMode: TWorkMode;
  AWorkCount: Int64);
  begin
    showmessage('hello im herre');
end;  

Problem is, that function isnt called... I don't know why.

I'm downloading 100 MB file, and i cant see any showmessage...

Have any idea ? Regards


The OnWork... events are only fired if the connection's BeginWork() method has been called beforehand. Many of Indy's reading/writing methods do not call that automatically. However, TIdHTTP reads/writes request/response body data using TStream objects, and the connection's read/write TStream methods do call BeginWork() internally, so you will definately get OnWork... events fired during HTTP operations.


Do you also assign the httpwork to the component? onprogress or onwork whatever it is called?

Also, use a label, not a modal component that will not return till you click, since that might interrupt download flow.


I'd have to say that your HTTPWork event is not hooked into the component. If you have the HTTP component on the form, bring up the properties and double-click on the OnWork event and then put in the ShowMessage...it should show up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜