等待FTP vb6中的下载完成

编程入门 行业动态 更新时间:2024-10-07 02:21:51
本文介绍了等待FTP vb6中的下载完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在名为"inetFTP"的表单上具有Internet传输控制.致电

I have an Internet Transfer Control on a form called "inetFTP". After I call

inetFTP.Execute , "Get " & "test.zip" & " " & "C:/test.zip"

我想暂停代码执行,直到下载完成,这样以后文件上就不会再有其他代码运行了,可能会遇到问题.有办法吗?

I want to pause the code execution until the download is finished, so there wouldn't be any other code operating on the file afterwards that could encounter problems. Is there a way to do that?

推荐答案

通常,您将使用控件的 StateChanged 事件并至少监视 icError 和 icResponseCompleted 状态.

Normally you'd use the control's StateChanged event and monitor for at least the icError and icResponseCompleted states.

但是在实际程序中,通常需要将其与Timer控件以及经过的时间计数器和取消标志一起使用.您将要确保您不会错过任何状态更改(如果它们快速连续发生,某些状态似乎不会触发该事件),处理超时,取消长时间运行的操作等.

But in real programs it is often necessary to use this along with a Timer control and an elapsed time counter and cancellation flag. You'll want to be sure you don't miss any state changes (some don't seem to fire the event if they occur in quick succession), to handle timeouts, to cancel long running operations, etc.

我怀疑控件中存在一些长期未解决的错误,这就是为什么 StateChanged 不够可靠的原因.其中一些可能与面向会话的FTP协议中的固有怪癖或竞赛条件有关.HTTP操作似乎更具确定性.

I suspect there are some long standing bugs in the control that have never been ironed out, which is why StateChanged isn't as reliable as one might hope. Some of this may relate to inherent quirks or race conditions in the session-oriented FTP protocol. HTTP operations seem quite a bit more deterministic.

从那里开始,您需要更改程序流程以正确适合Windows程序的模型.

From there you'd need to change your program flow to properly fit the model of a Windows program.

可以启动长时间运行的异步操作,但是在大多数情况下,只有收到更多值得做的事情",直到您收到完成信号(或中止操作等).

A long running async operation can be started, but then there is only so much more "worth doing" in most cases until you get a completion signal (or an abort, etc.).

因此,您要执行 Execute ,然后退出正在运行的事件处理程序.一旦发出完成信号,您便会在该完成事件处理程序中恢复处理.

So you do that Execute and then exit the event handler you are running in. Once completion is signaled you resume processing in that completion event handler.

VB6不是QBasic,Windows也不是DOS.

VB6 is not QBasic, and Windows is not DOS.

更多推荐

等待FTP vb6中的下载完成

本文发布于:2023-11-13 02:48:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583218.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:下载完成   FTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!