Home > Back-end >  URLDownloadToFile download network file card often death under the dynamic and how to set the timeou
URLDownloadToFile download network file card often death under the dynamic and how to set the timeou

Time:09-25

The network file such as: http://127.0.0.1/cd/xx.pdf
Very slow when the network disconnected or network file server to download the main program will always stuck in there when the interface feign death, how to set up a judgment that make them give up the download to download the next file? Please give idea

CodePudding user response:

Suggestion to download in one thread, thread, sets the timeout time, overtime to exit,
Best, will timeout is associated with the file size, so that more reasonable,

CodePudding user response:

Use thread processing, set the timeout

CodePudding user response:

Above two Daniel how to set the timeout in the thread for example also receive didn't

CodePudding user response:

Set the timeout in the thread I would

CodePudding user response:

This is a BUG of Microsoft, Microsoft solution is given in a thread

CodePudding user response:

reference 4 floor chinawcs response:
in the thread I would set the timeout


Through the thread they will take care of the timeout, finished automatically closed thread,
And shall not affect the main thread, won't have the feeling of the card

CodePudding user response:

In on the thread using WinInet API to download control block, the vast number of server support breakpoint continuingly,

CodePudding user response:

I am in multiple files to download if the thread in turn caused by speed has been waiting for the download is complete so will wait
I am circulating a single file download download into the multithreading a thread end begin to download another file

If a file is slow may have to wait a long time to have a better solution

CodePudding user response:

Sometimes a download Pdf 1 to 2 MB results waiting for an hour or two how to set the timeout in the thread? Continue to pray

CodePudding user response:

They are not said you download thread to set the timeout!

Are you use another thread to monitor your download threads,
I can give you an idea,,,
Existing thread A (download), B (supervisors, supervision of many), the timer (Stopwatch)
1. Be started, a single download, read the value of the timer as the stamp of the downloaders
2. When the callback is invoked, read the latest value of the timer as the stamp of the downloaders
3. The supervisors constantly, using the current value of the timer, to contrast the activities of the individual downloaders stamp
4. If more than the specified time, the inventory for overtime or wrong, and end goal downloaders directly

CodePudding user response:

MSDN: Microsoft WinHttp Reference
With c # example, is easy to implement,

CodePudding user response:

LpfnCB parameter BINDF
BINDF_ASYNCSTORAGE
The Value that are that the client application calling the IMoniker: : BindToStorage method specifies that the storage objects and stream objects returned from the IBindStatusCallback: : OnDataAvailable method return E_PENDING the when the objects reference data that is not yet available through the cost: : Read method, home blocking until the data becomes available. This flag applies only to BINDF_ASYNCHRONOUS operations.
  • Related