title: How do I create a class with asynchronous capabilities (similiar to SqlCommand or WebRequest)?
body: <p>I've been reading a lot about asynchronous programming recently, as I need to create a multi-threaded application. </p>
  
  <p>Unfortunately I can't seem to bring my newly acquired knowledge together into one cohesive and useful unit!</p>
  
  <p>I'm hoping someone can give me some pointers on how to construct the following:</p>
  
  <ul>
  <li><p>I have a class that does a lot of different (and time-consuming) tasks in a specified sequence.</p></li>
  <li><p>I'd like to instantiate this class in my Winforms UI thread. eg:</p>
  
  <pre><code>TaskRunner tr = new TaskRunner();
  </code></pre></li>
  <li><p>I'd like to be able to call a BeginAsync() method (as you can do with lots of the .NET built-in objects). eg:</p>
  
  <pre><code>tr.BeginAsync();
  </code></pre></li>
  <li><p>I'd like my class to callback to my UI thread when certain events arise (for logging, completion etc). </p></li>
  <li><p>I'd like to be able to cancel the execution of my class. eg:</p>
  
  <pre><code>tr.CancelAsync();
  </code></pre></li>
  </ul>
  
  <p>How do I go about building the internals of that class? I can't seem to find anything that talks about how the internals of SqlCommand or WebRequest might work.</p>