dimanche 25 octobre 2015

Looping through a method call too fast? [duplicate]

This question already has an answer here:

I am calling a method instance called buy. My method randomly generates a string of digits and numbers. My for loop appears to be going to fast for the method to change the string because I get the same string like 2-3 times in a row before getting a new string. when i add a System.Threading.Thread.Sleep(100); I am getting random number like the way it is supposed to be. The problem is that it is way too slow and i feel like there must be a better way. is there a way to get random string each time without invoking the Sleep() method?

for (int i = 0; i < exit; i++)
{
    ticket = buy.SetNum();
    Console.WriteLine("Wellcome Mr.Nissan. The winning numbers for Lotto max are:");
    Console.WriteLine(ticket);
    System.Threading.Thread.Sleep(25);
}




Aucun commentaire:

Enregistrer un commentaire