indy GET下载速度

发布于 2024-10-07 13:50:25 字数 509 浏览 0 评论 0原文

欢迎,

我必须使用 indy http get 组件在我的应用程序中创建包含有关下载速度信息的标题。

在我看来,我找到了简单的解决方案。

在工作活动中,我将获得下载的实际进度(大小)并将其与之前的阅读进行比较。 (例如每 5 秒一次)。当前大小减去先前的大小(5 秒eariel,存储在全局变量中)除以 5 秒 * 8,我将获得速度。 如果实际大小等于先前的值,则速度始终为 0。

所以我想开始编码,但我在名为 odwork 的简单函数中发现了问题。

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

问题是,该函数没有被调用...... 我不知道为什么。

我正在下载 100 MB 的文件,但看不到任何显示消息...

有什么想法吗? 问候

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千柳 2024-10-14 13:50:25

仅当事先调用了连接的 BeginWork() 方法时,才会触发 OnWork... 事件。 Indy 的许多读/写方法不会自动调用它。但是,TIdHTTP 使用 TStream 对象读取/写入请求/响应正文数据,并且连接的读/写 TStream 方法确实在内部调用 BeginWork(),因此您肯定会在 HTTP 操作期间触发 OnWork... 事件。

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.

傲影 2024-10-14 13:50:25

您是否也将 httpwork 分配给该组件? onprogress 或 onwork 无论它叫什么?

另外,请使用标签,而不是单击后才会返回的模态组件,因为这可能会中断下载流程。

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.

淡淡绿茶香 2024-10-14 13:50:25

我不得不说你的 HTTPWork 事件没有挂接到组件中。如果表单上有 HTTP 组件,请调出属性并双击 OnWork 事件,然后放入 ShowMessage...它应该会显示。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文