我的VB6程序,一执行到URLDownloadToFile()这个函数时,主界面就发白象死机一样,且界面不可操作,是什么问题
解决方案 »
- MSCOMM1与单片机通讯
- 简单的ListView vb6.0
- SQL语句insert into pp(H,S) select H,avg(A) as S from ct group by H,如何得到各组的记录个数呢?
- 一个菜鸟问题
- 文件夹操作
- 搞不定关于日期查询,大家帮我。在线。。。
- listbox的vbListBoxCheckbox,如何单击复选框后面的文字就能使复选框被选中?
- zyl910(910:如何获得键盘光标闪烁的X,Y位置,(不是当前鼠标的位置)?
- 请教高手如何在VB中实现2个EXE文件之间的捆绑?
- 如何在程序中监测是否连入interNET?
- 如何下载不固定地址文件?
- 设置桌面图片?
这就是单线程造成的 没有办法
----------------------------------------------------
因为URLDownloadToFile()这个函数执行时间比较长,占用cpu资源,就会像死机一样,解决办法只能是改进URLDownloadToFile()这个函数
inside the IBindStatusCallback::OnProgress implementation of your callback, peek and dispatch messages waiting in the message queue, then continue processing. the amount of bytes for downloading is the ulProgressMax parameter to IBindStatusCallback::OnProgress. Note that sometimes it is impossible for the client to know this data in advance before the download is complete. This depends on how the server chooses to format the request, and is not controllable from the client. In this case, ulProgressMax is 0. ulProgress is always the number of bytes downloaded so far.
Another alternative is using URLOpenPullStream instead. It is fully asynchronous.
为了避免GUI锁死,执行URLDownloadToFile()回调,在IBindStatusCallback::OnProgress内部等待转发的消息队列,然后继续执行。下载的总字节数是IBindStatusCallback::OnProgress的ulProgressMax参数。注意:有时这个数字对于客户端在下载完成前是未知的,这取决于服务器所选择的应答格式,客户端是无法控制的,这种情况下,ulProgressMax(总字节数)是0,ulProgress参数就是当前已下载的字节数。
可选的方法是使用URLOpenPullStream来代替,它完全异步的。抱歉啦,上半段有点狗屁不通,是因为自己也没完全看懂,呵呵