Je pensais que TaskEx.WhenAll reviendrait lorsque toutes les tâches terminées seront passées dans la méthode. Donc attendez sur TaskEx.WhenAll retournera le tableau des instructions de retour, de sorte que lorsque chaque objet aura fini, le tableau sera retourné.Qu'est-ce que `TaskEx.WhenAll` dans le CTP Async?
Mais ce n'est pas le cas. Quand je fais:
public async Task AsynchronousCallServerMordernParallelAsync()
{
List<Task<string>> lstTasks = new List<Task<string>>();
StringBuilder builder = new StringBuilder();
for (int i = 2; i <= 10; i++)
{
using (WebClient client = new WebClient())
{
try
{
this.tbStatus.Text = string.Format("Calling Server [{0}]..... ", i);
string currentCall = string.Format(Feed, i);
Task<string> task = client.DownloadStringTaskAsync(new Uri(currentCall));
lstTasks.Add(task);
}
catch (Exception ex)
{
this.tbStatus.Text = string.Format("Error Occurred -- {0} for call :{1}, Trying next", ex.Message, i);
}
}
string[] rss = await TaskEx.WhenAll<string>(lstTasks);
foreach(string s in rss)
builder.Append(s);
MessageBox.Show(string.Format("Downloaded Successfully!!! Total Size : {0} chars.", builder.Length));
}
}
Je vois mon MessageBox apparaît plus d'une fois, et attendre également les étapes avec tableau de 1 élément, puis tableau d'élément 2 et ainsi de suite.
Quelqu'un peut-il me dire quelle est exactement la nature de TakEx.WhenAll?
Ohh .. J'ai eu le problème ... Super! Merci .. J'ai juste négligé. – abhishek