title: Task.WaitAll Method (Task[], Int32) doesn't release the thread when it is expired
body: <p>Task.WaitAll Method (Task[], Int32) doesn't release the thread when it is expired.</p>
  
  <p>I'm using.net framework 4.0.
  I find that Task.WaitAll Method still occupy the thread when it's expired.</p>
  
  <p>I write below code to test it.</p>
  
  <pre><code>static void Main(string[] args)
          {
              printThreadCount("start");
              Task[] tasks = new Task[5];
              for (int i = 0; i &lt; 5; i++)//create tasks
              {
                  Task t = new Task(() =&gt;
                  {
                      Thread.Sleep(30000);
                      Console.WriteLine(DateTime.Now.ToString() + "task finish");
                  }
                 );
  
                 tasks[i] = t;
              }
  
              for (int i = 0; i &lt; 5; i++)
              {
                  tasks[i].Start();//start 1 task per second
                  Thread.Sleep(1000);
                  printThreadCount("start 1 task per second");
              }
  
              printThreadCount("before waitall");
              Task.WaitAll(tasks, 10000);
  
              printThreadCount("after waitall 10s");
              Thread.Sleep(5000);
              printThreadCount("sleep 5s");
              Thread.Sleep(5000);
              printThreadCount("sleep 5s");
              Thread.Sleep(5000);
              printThreadCount("sleep 5s");
              Thread.Sleep(5000);
              printThreadCount("sleep 5s");
  
              Console.WriteLine("end");
          }
  
          static void printThreadCount(string title)
          {
              int MaxWorkerThreads, MaxIOThreads;
              ThreadPool.GetMaxThreads(out MaxWorkerThreads, out MaxIOThreads);
              int AvailableWorkerThreads = 0;
              int AvailableIOThreads = 0;
              ThreadPool.GetAvailableThreads(out AvailableWorkerThreads, out AvailableIOThreads);
  
              Console.WriteLine();
              Console.WriteLine("*****************" + title + "********************");
  
              Console.WriteLine("active Worker Threads count:" + (MaxWorkerThreads - AvailableWorkerThreads));
              Console.WriteLine("active IO Threads count:" + (MaxIOThreads - AvailableIOThreads));
          }
  </code></pre>
  
  <p>I create 5 tasks,and start 1 task per second, each task will last 30 seconds. And Task.WaitAll will wait them for 10 seconds.
  Ideally, when the waitall expired, all of them are timeout. But they still occupy the thread. After enough time, all the task will finish and run  <code>Console.WriteLine(DateTime.Now.ToString() + "task finish")</code>, then all the threads are released.</p>
  
  <p>The result is as follow:</p>
  
  <p><img src="https://i.stack.imgur.com/ycXCk.jpg" alt="the result of above code"></p>
  
  <p>That's not a normal behavior for me. I want all the task are killed when time is over.
  How to kill them when the waitall time is expired??</p>