title: how to create a countdown timer in visual studio using datetimepicker
body: <p>this may sound stupid for some of you but please bear with me. I am trying to create a windows form application that has 2 datetimepicker controls. They are intended to set a time range (date selection has been disabled). After the user sets the range and hits the confirm button, the program needs to display 'A' till the limit and reached and when the timer expires, display 'B'. 
  This is my code right now in the click event of the confirm button</p>
  
  <pre><code>int a=0;
  TimeSpan time = DateTime.Now.TimeOfDay;            
  TimeSpan timer = dateTimePicker2.Value - dateTimePicker1.Value;
  MessageBox.Show("Timer set. Device will shutdown in " + timer);
  timer = timer + time;            
  while (time!=timer)
  {
      time = DateTime.Now.TimeOfDay; ;
      if(a==0)
      {
          MessageBox.Show("B");
          a = 1;
      };               
  };
  if (a == 1)
  {
      MessageBox.Show("A");
      a = 0;
  }
  </code></pre>
  
  <p>My logic behind this piece of code was this: First find the difference between the two time ranges. Then add this difference to the current system time and do a while loop to check if that time has reached.If not display B. When the current system time reaches the time, display A. I have spend hours over this and cant get it working. When running this code it just displays B and never A.
  I'm new to visual studio and this is my first project.</p>