Question:
I am using the HTTP Download functionality to download files during a web request. It seems that if I use a loop download more than one file, the thread detaches from my web session. Is there something I can do to ensure the downloads always remain in the active thread?
I don't understand the question. Maybe a code snippet showing what you are doing might help?
This is the code I'm running. If I step into it, then after the download, sometimes the debugger starts jumping back and forth between this loop and code that happens after it.
Chilkat.Http http = new Chilkat.Http();
if (http.UnlockComponent("30-day trial"))
{
bool isError = false;
string localPath = string.Empty;
foreach (RemoteImage remoteImage in remoteImages.ImageList)
{
localPath = Path.Combine(imageDownloadFolder, Path.GetFileName(remoteImage.Url));
if (!http.Download(remoteImage.Url, localPath))
{
//Log errors
}
else
{
remoteImage.LocalPath = localPath;
}
}
if (isError)
return Types.RemoteImageProcessingStatus.error;
}
It appears to have been caused by breakpoints in my source. If I remove the breaks it works fine. Thanks.