title: Creating dispatcher timer
body: <p>I want to create a new dispatcher timer, with different periods each time method foo(30) is called using a timer value:</p>
  
  <pre><code>void foo(int timerValueInSeconds)
  {
              TimeSpan _DestructionTimer = TimeSpan.FromSeconds(timerValueInSeconds);
              DateTime _FullDestructionTimer = DateTime.Now + _DestructionTimer;
  
              DispatcherTimer _DispatcherTimer = new DispatcherTimer();
              _DispatcherTimer.Interval = TimeSpan.FromMilliseconds(1000);
              _DispatcherTimer.Tick += new EventHandler((sender, e) =&gt; DispatcherTimer_Tick(sender, e, _FullDestructionTimer, _NewMessage, _DispatcherTimer));
              _DispatcherTimer.Start();
  }
  
  private void DispatcherTimer_Tick(object sender, EventArgs e, DateTime timer, Message _message, DispatcherTimer _dispatcherTimer)
  {
      var remaining = timer - DateTime.Now;
      int remainingSeconds = (int)remaining.TotalSeconds;
  
      //update timer in view
      _message.Timer.ValueInSeconds = remainingSeconds;
  
      //stop the timer if reach to zero
      if (remaining.TotalSeconds &lt;= 0)
      {
          _dispatcherTimer.Stop();
  
          //remove message from list 
      }
  }
  </code></pre>
  
  <p>When I call foo(30) three times, I expect each timer should run in a different parallel thread, with its specified period, updating the view after each one is finished independently.  </p>
  
  <p>I call foo(30), then wait (for example) 3 seconds, then call foo(30) again. The timer is counting down depending on a previous count down timer value (which is 27s), and then it counts down with same value.</p>