title: In C#, can I start a background operation, kill it and get its stack trace?
body: <p>In my C# application (unit test, actually) I want to be able to launch an operation and set a timeout. If the timeout elapses and my operation has not terminated, I want to:</p>
  
  <ol>
  <li>Throw an exception.</li>
  <li>Include a stack trace of the thread running the operation.</li>
  <li>If reasonably convenient, cancel the operation. </li>
  </ol>
  
  <p>I can accomplish point #1 using the method described in this answer by Lawrence Johnston: <a href="https://stackoverflow.com/a/22078975/8557153">https://stackoverflow.com/a/22078975/8557153</a></p>
  
  <p>How can I accomplish point 2? I have a reference to a Task, but I know that Task objects do not have stack traces per se. A Task just a data structure of some kind. Only threads have stack traces. But is there any way to get a stack trace from the thread running the task, if any? Or will I need to completely rewrite the body of my task to make this possible? </p>
  
  <p>Point 3 is optional. It is acceptable to have the task continue unawaited in the background, but it would be nice to abort it.</p>