title: Implementing IAsyncResult explicitly
body: <p>I am generally wary of implementing interfaces partially. However, <code>IAsyncResult</code> is a bit of a special case, given that it supports several quite different usage patterns. How often do you use/see used the <code>AsyncState</code>/<code>AsyncCallback</code> pattern, as opposed to just calling <code>EndInvoke</code>, using <code>AsyncWaitHandle</code>, or polling <code>IsCompleted</code> (yuck)?</p>
  
  <p>Related question: <a href="https://stackoverflow.com/questions/405600/detecting-that-a-threadpool-workitem-has-completed-waiting-for-completion">Detecting that a ThreadPool WorkItem has completed/waiting for completion</a>. </p>
  
  <p>Consider this class (very approximate, locking needed):</p>
  
  <pre><code>public class Concurrent&lt;T&gt; {
      private ManualResetEvent _resetEvent;
      private T _result;
  
      public Concurrent(Func&lt;T&gt; f) {
          ThreadPool.QueueUserWorkItem(_ =&gt; {
                                           _result = f();
                                           IsCompleted = true;
                                           if (_resetEvent != null)
                                               _resetEvent.Set();
                                       });
      }
  
      public WaitHandle WaitHandle {
          get {
              if (_resetEvent == null)
                  _resetEvent = new ManualResetEvent(IsCompleted);
              return _resetEvent;
          }
  
      public bool IsCompleted {get; private set;}
      ...
  </code></pre>
  
  <p>It has <code>WaitHandle</code> (lazily created, just as described in <code>IAsyncResult</code> documentation) and <code>IsCompleted</code>, but I don't see a sensible implementation for <code>AsyncState</code> (<code>{return null;}</code>?). So does it make sense for it to implement <code>IAsyncResult</code>? Note that <code>Task</code> in the Parallel Extensions library does implement <code>IAsyncResult</code>, but only <code>IsCompleted</code> is implemented implicitly.</p>