title: C# task factory timeout
body: <p>I have to execute a long process operation in a thread and continue by returning the result to a function. Here is my code :</p>
  
  <pre><code>Task&lt;ProductEventArgs&gt;.Factory.StartNew(() =&gt;
      {
          try
          {
               // long operation which return new ProductEventArgs with a list of product
  
          }
          catch (Exception e)
          {
              return new ProductEventArgs() { E = e };
          }
  
      }).ContinueWith((x) =&gt; handleResult(x.Result), TaskScheduler.FromCurrentSynchronizationContext());
  </code></pre>
  
  <p>The problem is actually I don't have a timeout. I want to put a timer in order to return something like this : </p>
  
  <pre><code>   new ProductEventArgs() { E = new Exception("timeout") }; 
  </code></pre>
  
  <p>if the timeout is reached.
  Can't use await/async.
  Thanks a lot !</p>