jeudi 24 octobre 2019

Random number same in different processes [duplicate]

This question already has an answer here:

I am using the following code to generate a unique Application InstanceID for logging.

public MainWindow()
{
    InitializeComponent();

    Random rnd = new Random();

    instanceID = rnd.Next(100000, 999999);

    /// ...
}

my App starts with the server as different services (with nssm) 2 and more Times with different Parameters. My Problem: if they start at the same time (same second), instanzID is the same, if 1 or more second difference instanzID is different. How can i avoid this?




Aucun commentaire:

Enregistrer un commentaire