Click here to Skip to main content
15,883,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing a windows application which downloads multiple files. The application has to process\execute those files in the background after each file downloaded. So I have used the background worker to perform the download action and execute the downloaded file. Download and file execution is working fine till having a proper network connection. If there is any connection problem, then download skipped to the next file.

But I want to pause the download for a while (2,3 minutes) and resume it after reconnecting the network. In the meantime, file execution process should be performed in the background.

What I have tried:

Using webclient (below code), I am performing the download action.
using (WebClient client)
{
try
{
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged(applicationName));
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted(fileSize, applicationName));
await AsyncPlatformExtensions.DownloadFileTaskAsync(client, new Uri(sourceUri), outputDir);
}
catch (WebException exe)
{
}       
}                   
Posted
Comments
Afzaal Ahmad Zeeshan 30-Oct-18 13:33pm    
Do you have control of both, server and client app?

You might want to learn how peer-to-peer networks work. Direct downloads normally happen on a socket connection, and server might not be able to remember how much it had sent to the client in case the connection is lost. Pause might be possible, if server and client both support the feature.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900