Strano che dei download sincroni siano ignorati.
Prova questo test come applicazione console, ora ho provato e qui mi partono solo 2 download contemporanei, gli altri download restano fermi finchè non si libera uno di questi 2 slot e a quel punto partono, alla fine tutti i file sono scaricati ma deve esserci qualche limite:
Codice:
using System;
class Program
{
const string indirizzoDL = "http://prova/prova";
static void Main(string[] args)
{
for (int i = 1; i <= 5; i++)
{
// avvio ciascun download in un thread differente
System.Threading.Thread myStart = new System.Threading.Thread(myDL);
// metto un nome personalizzato col numero
myStart.Name = "Thread" + i;
myStart.Start();
}
//questo per evitare che termini
do
{
System.Threading.Thread.Sleep(1000);
} while (true);
}
static void myDL()
{
try
{
System.Net.WebClient myWebClient = new System.Net.WebClient();
string myDest = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString());
string tName = System.Threading.Thread.CurrentThread.Name;
Console.WriteLine(string.Format("{0:G} - {1} Iniziato", DateTime.Now, tName));
myWebClient.DownloadFile(new System.Uri(indirizzoDL), myDest);
Console.WriteLine(string.Format("{0:G} - {1} Completato - " + myDest, DateTime.Now, tName));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
Segnalibri