title: When does a C# Task terminate?
body: <p>I am working with ASP.NET. When I run a new Task, at what point will that Task terminate? Will it terminate when the thread that called it terminates? Or will it continue on until it has finished running the code within my lambda expression?</p>
  
  <p>Here is an example of what I am trying to do:</p>
  
  <pre><code>Task.Run(() =&gt;
  {
      try
      {
          MyFunction();
      }
      catch (Exception ex)
      {
          Console.Write(ex);
      }
  });
  </code></pre>
  
  <p>MyFunction() does not return anything, I simply want it to start running on its own so that the current thread can continue. When I run my application and call this code, it seems to work just fine. I am just trying to see if I should be worried about the task spontaneously terminating or if I will be just fine.</p>
  
  <p>I also should mention that the thread that makes the request is probably going to terminate before the Task finishes.</p>
  
  <p>Thanks.</p>