如何使用 TIdTCPClient 实现进度条?
我正在使用 indy 10,我想知道如何实现传输文件的进度条。我尝试使用 onWork 事件,但它们没有被触发。我觉得烦人的另一件事是应用程序冻结直到下载流。
我做错了什么?
I am using indy 10 and i was wondering how can i implement a progress bar for transfering a file.I tried with onWork events but they are not triggred. Another thing that i find anoying is that the application freezes until the stream is downloaded.
What am i doing wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 IdAntiFreeze 组件添加到表单中,并使用它的属性和事件来获取网络操作进度的通知。
Add an IdAntiFreeze component to your form and use it's properties and events to get notified of the progress of the network operations.
您可以使用
TThread
将下载代码放入另一个线程中,以便您的应用在下载时不会冻结,并有一个发送到TThread.Synchronize
的过程来更新进度条。另外,要调用OnWork
,您必须先调用OnWorkBegin
,请参阅You can put the download code into another thread using
TThread
so that your app doesn't freeze while downloading, and have a procedure that you send toTThread.Synchronize
to update the progress bar. Also, forOnWork
to be called, you have to callOnWorkBegin
first, see http://www.borlandtalk.com/image-vp569607.html