title: Killing/Aborting a thread with a single, giant task (e.g. SQL Query)
body: <p>Okay,</p>
  
  <p>There seems to be a lot of discussion on here about how terribly awful Thread.Abort() is, and how to work around using Thread.Abort() in your code by adding exit checks in your loop.</p>
  
  <p>This assumes that you control how the work is being partitioned in a way that's granular enough to loop over it.</p>
  
  <p>But how do I do the following:</p>
  
  <ol>
  <li><p>Launch worker thread to do something while keeping the UI responsive.  For all intents and purposes the code for the worker thread looks like this:</p>
  
  <pre><code>public override void Run()
  {
      try
      {
          _dataTable = ExecuteSingleGinormousSqlQuery();
      } finally
      {
          // close the connection if it was left open.
      }
  }
  </code></pre></li>
  <li><p>Have "Cancel" button so that the user can interrupt this if they get bored of waiting.</p></li>
  </ol>
  
  <p>It doesn't seem like there's any other way around this than with Thread.Abort().  Is that true?  Furthermore, in empirical tests, it doesn't even seem like Thread.Abort() actually kills the thread until the call that is making the query, e.g. </p>
  
  <pre><code>    new SqlDataAdapter(cmd).Fill( ds );
  </code></pre>
  
  <p>comes back in the first place, thus significantly negating its utility.</p>
  
  <p>Is there a way around this?  Best practices?</p>