title: C# Nested Tasks -> Get time when tasks are over
body: <p>i want to show the time my background tasks need for doing some work. </p>
  
  <p>I have:</p>
  
  <pre><code>   Stopwatch sw = new Stopwatch();
          Task.Run(() =&gt;
          {
              sw.Start();
              function();
              sw.Stop();
          }
          ).ContinueWith(t =&gt; StatusText =sw.Elapsed.ToString());
  </code></pre>
  
  <p>and the function looks something like this:</p>
  
  <pre><code>    function()
  {
  Task.Run({...});
  Task.Run({...});
  }
  </code></pre>
  
  <p>Now my Stopwatch just shows me a millisecond value because of the nested tasks. how can i show the real time my task needs to complete all the work in the function?</p>