title: Is there an effective way to use System.Threading.Tasks with WCF service proxies?
body: <p>After reading a <a href="http://msdn.microsoft.com/en-us/magazine/ff959203.aspx" rel="nofollow noreferrer">recent MSDN Magazine article about the Task scheduler</a> I was hoping (and actually quite excited) that using it would benefit my use of WCF generated proxies.</p>
  
  <p>I was hoping to get some of the following benefits :</p>
  
  <ul>
  <li><strong>1) Ability to abort a running WCF operation</strong> (I'm not expecting this to stop the operation on the server - I'd just like to be able to signal that 'I don't want the result for this task'. This is especially common in UI where someone repeatedly selects items from a grid that trigger service calls.)</li>
  <li><strong>2) Ability to start a task at some point other than when it was created</strong> - I'm not sure I really <em>need</em> this, I just thought it might be nice to generate a task and not immediately run it. After all I thought that was the whole point of tasks.</li>
  <li><strong>3) Bindable properties</strong> - so I can bind my WCF UI to <code>IsCompleted</code> and let the Task class abstract away the operation's internals from my UI.</li>
  <li><strong>4) Ability to abstract away the running of the operation</strong> - mocking, blah blah blah, future refactoring etc.</li>
  </ul>
  
  <p>However - I don't seem to get ANY of these benefits.</p>
  
  <ul>
  <li>1) There is no abort functionality in Task - which strikes me as really odd.</li>
  <li>2) The only overload that I could get working with <code>Task.Factory.FromAsync&lt;&gt;</code> is the one shown below. This immediately begins execution of the webservice operation (as seen in Fiddler) and doesn't let me start the call later.</li>
  <li>3) Task doesn't implement <code>INotifyPropertyChanged</code> so i can't bind it to the UI.</li>
  <li>4) This one is kind of dead in the water given the other 3 benefits aren't happening :-(</li>
  </ul>
  
  <p>Sooo.... Am i just wasting my time trying to get WCF generated proxies working with Tasks -- or am I missing something.</p>
  
  <pre><code>// WCF client
  var client = new ShoppingCartClient();
  
  // create task
  var t = Task.Factory.FromAsync&lt;GetOrderDetailsMsgOut&gt;(
                client.BeginGetOrderDetails(new GetOrderDetailsMsgIn()
                {
                    OrderId = 12345
                },  null, null),    
                client.EndGetOrderDetails);
  
  t.ContinueWith(x =&gt;
  {
      var order = x.Result.Order;
      // do something with order
  }); 
  </code></pre>