us**@domain.invalid wrote:
Hello
i call it in almost same time (from two different threads):
Random rand = new Random();
id=rand.Next(65535);
and i often receive the same results.
Is it possible ? How windows count this random ?
Thanx
Random is *not* a random number generator, but rather a *pseudo* random number
generator. Given the same seed, it will always produce the same number
sequence.
From the help:
The random number generation starts from a seed value. If the same seed is used
repeatedly, the same series of numbers is generated. One way to produce
different sequences is to make the seed value time-dependent, thereby producing
a different series with each new instance of Random.
The trick is to use a random seed. In your case, a good candidate for the seed
might be the thread id.