خرید بک لینک

Vote count: 0

I have my program creating an array based on a time RNG, and whenever I do Thread.Sleep(120); it works fine to get my different numbers, however I have a display that's supposed to populate (Label) right after the random number has been generated. In my case, this does not happen. As the program itterates this function, it seems that it does all the calculations beforehand then shows the numbers. If I put a forced stop, such as a MessageBox.Show(" "); after the box shows up, the number that is supposed to be inserted into the box, is done at the same time, instead of after all numbers have been given.

My code is this:

 void createArray()
 {
     var label = new List<Label> { label1, label2, label3, label4, label5, label6, label7, label8, label9 };
     double[,] board = new double[3, 3];
     for (int i = 0; i != 3; i++)
     {
         for (int o = 0; o != 3; o++)
         {
             board[i, o] = randomnumber();
             Thread.Sleep(120);
             int tmp = i * 3;
             int listNum = tmp + o;
             label[listNum].Text = board[i, o].ToString("n0");
         }
      }

   }

It seems that my code waits roughly a second and a half before displaying all the numbers, I want it to display each number as it makes them, every 120 ms.

asked 45 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 18 فروردين 1395 ساعت: 9:39

صفحه بندی