Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion TPL... Tasks... etc.
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Florian Nouri  
View profile   Translate to Translated (View Original)
 More options Aug 8 2012, 4:35 am
From: Florian Nouri <florian.no...@gmail.com>
Date: Wed, 8 Aug 2012 10:35:13 +0200
Local: Wed, Aug 8 2012 4:35 am
Subject: Re: [alt.net.fr] TPL... Tasks... etc.
En fait ce que j'essaie d'avoir c'est un truc du genre :

Task[] tasks = new Task[]{t0,t1,t2,t3,t4};
Task<bool> t = Task.WhenAny(tasks, t => t.Result = true); // Condition
qui dit quand une tâche est terminé et que le résultat est True

2012/8/8 Bruno Baia <brb...@gmail.com>:

> Salut,

> As tu essayé Task.WaitAny ?

> - Bruno

> Le 8 août 2012 10:04, Florian <florian.no...@gmail.com> a écrit :

>> Bonjour à tous,

>> je me permets de poser une petite question... Je voulais savoir quel était
>> le moyen "conseillé" pour récupérer la première tâche terminée qui retourne
>> un résultat particulier attendu (true pour faire simple) :

>> aujourd'hui j'ai ça :

>> Task<bool> t0 = Task.Factory.StartNew<bool>(() => Find(paramA, paramB));

>> Task<bool> t1 = Task.Factory.StartNew<bool>(() => Find(paramC, paramD));

>> Task<bool> t2 = Task.Factory.StartNew<bool>(() => Find(paramE, paramF));

>> Task<bool> t3 = Task.Factory.StartNew<bool>(() => Find(paramG, paramH));

>> Task.WaitAll(new Task[] { t0, t1, t2, t3, t4 });

>> return t0.Result | t1.Result | t2.Result | t3.Result | t4.Result;

>> mais je voudrais que dès qu'une tâche renvoie true, alors je renvoie
>> directement true et je n'attend pas que toutes les tâches soit terminées.

>> Il y a un moyen de faire ça simplement ?

>> Merci pour vos suggestions

>> Question subsidiaires : Une fois qu'une tâche a renvoyé true, est-ce qu'il
>> vaut mieux annuler l'exécution des autres  tâches en cours ou bien les
>> laisser terminer leurs exécutions normalement.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.