Prev: Weird behavior / bug(?) with VC++ Studio 2005 (Beta 2)
Next: Invoking WebBrowser Object from a windowless application
From: nly on 4 Sep 2005 01:27 URLDownloadToFile is a blocking function. To avoid hang of GUI, if to make use of the URLDownloadToFile() callback, inside the callback, peek and dispatch messages waiting in the message queue, then continue processing. void OnProgress() { MSG msg; while (PeekMessage(&msg,0,0,0,PM_NOREMOVE)){ TranslateMessage(&msg); DispatchMessage(&msg); } // Do extra processing //... } What I concern here is that how often the OnProgress() will be called back, since downloading a big file could take too long for between callbacks? Thanks in advance!
From: Igor Tandetnik on 4 Sep 2005 20:58 "nly" <nlyee2001(a)yahoo.com> wrote in message news:eEv5eDRsFHA.904(a)tk2msftngp13.phx.gbl > URLDownloadToFile is a blocking function. > > To avoid hang of GUI, if to make use of the URLDownloadToFile() > callback, inside the callback, peek and dispatch messages waiting in > the message queue, then continue processing. Consider using URLOpenPullStream instead. It is fully asynchronous. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: nly on 5 Sep 2005 20:13 Igor Tandetnik <itandetnik(a)mvps.org> wrote in message news:OL1NdTbsFHA.2540(a)TK2MSFTNGP09.phx.gbl... > "nly" <nlyee2001(a)yahoo.com> wrote in message > news:eEv5eDRsFHA.904(a)tk2msftngp13.phx.gbl > > URLDownloadToFile is a blocking function. > > > > To avoid hang of GUI, if to make use of the URLDownloadToFile() > > callback, inside the callback, peek and dispatch messages waiting in > > the message queue, then continue processing. > > Consider using URLOpenPullStream instead. It is fully asynchronous. > -- > With best wishes, > Igor Tandetnik > > With sufficient thrust, pigs fly just fine. However, this is not > necessarily a good idea. It is hard to be sure where they are going to > land, and it could be dangerous sitting under them as they fly > overhead. -- RFC 1925 > > Thanks for the suggestion of using URLOpenPullStream(). MSDN says "The pull model is slightly more cumbersome than the push model, but it allows the client to control the amount of Internet access for the download." How does URLOpenPullStream() "control the amount of Internet access for the download"? Where can the amount of bytes for downloading specified?
From: Igor Tandetnik on 6 Sep 2005 00:22
"nly" <nlyee2001(a)yahoo.com> wrote in message news:%2323C$cnsFHA.1204(a)TK2MSFTNGP15.phx.gbl > How does URLOpenPullStream() "control the amount of Internet access > for the download"? The download is paused until you empty out the current contents of the stream. You can control the speed of the download by choosing to either read agressively from the stream, or stop reading for a while. > Where can the amount of bytes for downloading > specified? Normally, it comes as 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. -- With best wishes, Igor Tandetnik With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925 |