我的VB6程序,一执行到URLDownloadToFile()这个函数时,主界面就发白象死机一样,且界面不可操作,是什么问题

解决方案 »

  1.   

    URLDownloadToFile() 这个函数没有返回值之前 界面不能响应外界事件
    这就是单线程造成的 没有办法
      

  2.   

    我的VB6程序,一执行到URLDownloadToFile()这个函数时,主界面就发白象死机一样,且界面不可操作,是什么问题
    ----------------------------------------------------
    因为URLDownloadToFile()这个函数执行时间比较长,占用cpu资源,就会像死机一样,解决办法只能是改进URLDownloadToFile()这个函数
      

  3.   

    To avoid hang of GUI, implement a URLDownloadToFile() callback, 
    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. 
      

  4.   

    我就来做做翻译工作啦:
    为了避免GUI锁死,执行URLDownloadToFile()回调,在IBindStatusCallback::OnProgress内部等待转发的消息队列,然后继续执行。下载的总字节数是IBindStatusCallback::OnProgress的ulProgressMax参数。注意:有时这个数字对于客户端在下载完成前是未知的,这取决于服务器所选择的应答格式,客户端是无法控制的,这种情况下,ulProgressMax(总字节数)是0,ulProgress参数就是当前已下载的字节数。
    可选的方法是使用URLOpenPullStream来代替,它完全异步的。抱歉啦,上半段有点狗屁不通,是因为自己也没完全看懂,呵呵
      

  5.   

    Mndsoft上有得代码哦,,,,VB的http://www.mndsoft.com/blog/blogview.asp?logID=611