title: Setting Timer to alternate between two intervals for random number generation
body: <p>I want to display two different randomly generated numbers in two different text boxes. The numbers in the text boxes change every second. I am invoking System.Random to create the random numbers:</p>
  
  <pre><code>    private int RandomNumber(int min, int max)
      {
          Random random = new Random();
          return random.Next(min, max);
      }
  </code></pre>
  
  <p>The issue I am running into is that System.Random generates numbers based upon the system time, so the text boxes generate two identical random numbers every second of the tick. I have tried to approach this problem by staggering generation of the numbers by 20 ms. I have done this by creating two different timers (one for each text box) that alternate  between 980 and 1020 ms intervals:</p>
  
  <pre><code>    private void timer1_Tick(object sender, EventArgs e)
      {
          int xgpscoord;
  
          timer1.Interval = 980;
          xgpscoord = RandomNumber(10000, 90000);
          textBoxGPSx.Text = xgpscoord.ToString();
          timer1.Interval = 1020;
  
  
      }
  
      private void timer2_Tick(object sender, EventArgs e)
      {
  
          int ygpscoord;
  
          timer2.Interval = 1020;
          ygpscoord = RandomNumber(10000, 90000);
          textBoxGPSy.Text = ygpscoord.ToString();
          timer2.Interval = 980;
  
  
      }
  </code></pre>
  
  <p>However, this does not synchronize the timers. I want them to tick every 1000 ms simultaneously. I think (correct me if I am wrong) that I am setting the intervals in the wrong places and only one of the two intervals that I set in each timer is actually being counted.</p>
  
  <p>If there is a better way to generate random numbers within c# not based upon system time, that would solve my problem as well. </p>