title: How to stop all tasks when one is finished in c#
body: <p>I have different tasks to read from different files and find a word into them. I have put them into a task array which I start with waitAny method as following :</p>
  
  <pre><code>foreach (string file in filesList)
          {
              files[i] = Task.Factory.StartNew(() =&gt;
              {
                  mySearch.Invoke(file);
              });
              i++;
          }
          System.Threading.Tasks.Task.WaitAny(files);
  </code></pre>
  
  <p>I would like to stop all other tasks as soon as one of the tasks finishes (it finishes when it founds the word). For the moment, with waitany, i can know when one tasks finishes, but I don't know how I could know which one has finished and how to stop other tasks.
   What would be the best way to achieve this ?</p>