title: C#: CancellationToken doesn't cancel blocking method
body: <p>.NET 4.5.1: It appears, I can't cancel a blocking method running inside a task using the CancellationTokenSource built-in timeout. </p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var cts = new System.Threading.CancellationTokenSource();
  
          System.Console.CancelKeyPress += (s, e) =&gt;
          {
              e.Cancel = true;
              cts.Cancel();
          };
  
          MainAsync(args, cts.Token).Wait();
      }
  
      // MainAsync from http://stackoverflow.com/questions/9208921/async-on-main-method-of-console-app
      static async Task MainAsync(string[] args, System.Threading.CancellationToken token)
      {
          Console.WriteLine("Starting MainAsync");
          var cts = new System.Threading.CancellationTokenSource(3000);
          var task = Task.Factory.StartNew(() =&gt;
          {
              Console.WriteLine("Starting task...");
              var t = new System.Net.Sockets.TcpClient();
              var buffer = new byte[t.ReceiveBufferSize];
              t.Connect(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 1337));
  
              Console.WriteLine("Recieving...");
              t.Client.Receive(buffer);
              Console.WriteLine("Finished Recieving...");
  
              return true;
          }, cts.Token);
  
          var success = await task;
  
          Console.WriteLine("Did the task complete succesfuly?", success);
      }
  }
  </code></pre>
  
  <p>The output from the above Short, Self Contained, Correct Example (I hope it's correct) is:</p>
  
  <pre><code>Starting MainAsync
  Starting task...
  Recieving...
  </code></pre>
  
  <p>Why does the task doesn't cancel, no exception is thrown?</p>