我使用以下代码在按钮点击下载PDF文件。我们如何在线程池中下载2个文件?
private async Task DownloadPDF(string urls, string shortName, object downloadProgressCalculator)
{
m_downLoadProgress = downloadProgressCalculator as DownloadProgressCalculator;
var pathFile = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
var absolutePath = pathFile.AbsolutePath;
var m_documentMobiNames = shortName + ".pdf";
var mobileFileNames = Path.Combine(absolutePath, m_documentMobiNames);
ThreadPool.QueueUserWorkItem((object state) =>
{
try
{
if (File.Exists(mobileFileNames))
{
File.Delete(mobileFileNames);
}
if (!File.Exists(mobileFileNames))
{
m_webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
m_webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
m_webClient.DownloadFileAsync(new Uri(urls), mobileFileNames);
}
}
catch (Exception ex)
{
}
});
}
请就此提出自己的想法。
由于