title: C# Countdown Accumulation Timer
body: <p>I have an application where I will be displaying a timer.</p>
  
  <p>A user will perform an event and should complete it in a certain amount of time.
  I currently have a timer that shows their time ticking down, but what I want now is a total accumulated time.  So every time a new event starts, the time to complete the event is added to their accumulated time.  Then as they are performing the event, the time is ticking off the accumulated time.  </p>
  
  <p>This is what I have for the "current timer"</p>
  
  <pre><code>u.StartingTime = u.ChangeOverStandard;
  u.CurrentChangeOverTime = u.StartingTime - (DateTime.Now - u.ChangeOverStart);
  </code></pre>
  
  <p>All of these fields are timespans.  This works perfect for their "current" timer</p>
  
  <p>But I need a "total" timer that will either show a positive timespan value..if they are getting done before they are supposed to...or a negative timespan value if they are taking too long.</p>
  
  <p>EDIT: </p>
  
  <p>So I want to achieve this:</p>
  
  <p>For example : for "event 1", user has 30 sec. to end. Then user has a "TotalTimespan" property = 30. This total is decreased with the event timer. Let's say he finishes in 24 sec. That means he's got 6 sec left in TotalTimespan. Then "event2" must be finished in 40 sec. So in the begining of event2, TotalTimespan = TotalTimespane(6) + 40. = 46. If user uses 60 seconds, then TotalTimespan = 46 -60 = -14.</p>
  
  <p>The "timer" is not a timer, and can't be used as a timer.  It is running on a background worker which is doing several other calculations as well.  So I can't just take off the time one second at a time. </p>
  
  <p>On each new event, I've tried</p>
  
  <pre><code>u.AccumulatedTime += u.ChangeOverStandard;
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>u.AccumulatedTime -= u.StartingTime - (DateTime.Now - u.ChangeOverStart);
  </code></pre>
  
  <p>But obviously that isn't going to work because it is taking the total elapsed time from the accumulated time every round through my loop</p>
  
  <pre><code>DateTime.Now - u.ChangeOverStart
  </code></pre>
  
  <p>^^Will give me the elapsed time from the beginning of the event to now, so is this what I'm wanting? </p>
  
  <pre><code>u.AccumulatedTime -= DateTime.Now - u.ChangeOverStart;
  </code></pre>