title: CancellationTokenSource.Cancel(false)
body: <pre><code>    static void Main(string[] args)
      {
          CancellationTokenSource cts = new CancellationTokenSource();
  
          ThreadPool.QueueUserWorkItem(o =&gt; DoWork(cts.Token, 100));
  
          Thread.Sleep(500);
  
          try
          {
              cts.Token.Register(CancelCallback3);
              cts.Token.Register(CancelCallback2);
              cts.Token.Register(CancelCallback1);
  
  
  
              cts.Cancel(false);
          }
          catch (AggregateException ex)
          {
              foreach (Exception curEx in ex.Data)
              {
                  Trace.WriteLine(curEx.ToString());    
              }
  
          }
  
          Console.ReadKey();
      }
  
      private static void CancelCallback1()
      {
          Trace.WriteLine("CancelCallback1 was called");
          throw new Exception("CancellCallback1 exception");
      }
  
  
      private static void CancelCallback2()
      {
          Trace.WriteLine("CancelCallback2 was called");
          throw new Exception("CancellCallback2 exception");
      }
  
      private static void CancelCallback3()
      {
          Trace.WriteLine("CancelCallback3 was called");
      }
  
      private static void DoWork(CancellationToken cancellationToken, int maxLength)
      {
          int i = 0;
          while (i &lt; maxLength &amp;&amp; !cancellationToken.IsCancellationRequested)
          {
              Trace.WriteLine(i++);
              Thread.Sleep(100);
          }
      }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>0
  1
  2
  3
  4
  CancelCallback1 was called
  </code></pre>
  
  <p>According to <a href="http://msdn.microsoft.com/en-us/library/dd321703.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/dd321703.aspx</a> I expected to get AggregateException, it looks like that throwOnFirstException parameter doesn't make any sense here. What's wrong with my code. </p>