5

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

marc
  • 2,963
  • 7
  • 24
  • 25

3 Answers3

2

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.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
0

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.

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
  • Right now, i add manually initation of onwork
      form1.Http := TIdHTTP.Create(nil);
      form1.Http.OnWork:=form1.HttpWork; 
    but compiler fail
    unit1.pas(356,36) Error: Wrong number of parameters specified for call to "HttpWork"
    
    I just add that showmessage to know where function will be triggered... i try memo1.lines.add('test'); but also didn't work ;)
    – marc Dec 11 '10 at 11:53
  • wrong number of parameters appears when the expected number of parameter for HttpWork even is different than the number of parameters the method that you assin has. Please copy-paste code here so that people will be able to help you, otherwise there is not much information. –  Dec 11 '10 at 14:05
0

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.

Darian Miller
  • 7,808
  • 3
  • 43
  • 62