Skip to content

Instantly share code, notes, and snippets.

@monyskynet
Created August 8, 2013 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monyskynet/6181957 to your computer and use it in GitHub Desktop.
Save monyskynet/6181957 to your computer and use it in GitHub Desktop.
List<Task<bool>> tasks = servers.Select(s => Task<bool>.Factory.StartNew(server => CallServer((string)server), s)).ToList();
bool result;
do {
int idx = Task.WaitAny(tasks.ToArray());
result = tasks[idx].Result;
tasks.RemoveAt(idx);
} while (!result && tasks.Count > 0);
// cancel other tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment