Exemplo n.º 1
0
 //This method is used to add new workers once new logins have been defined
 public void AddMissingWorkers()
 {
     //Obtain a lock on the workers, since the user might be causing this to be called concurrently from the GUI and from the startup procedure
     lock (Workers)
     {
         foreach (var profile in Configuration.RegionProfiles)
         {
             //Obtain a lock on this profile because it is concurrently being modified by the user in the edit dialogue
             lock (profile)
             {
                 if (profile.Login == null)
                 {
                     //No login has been specified for this region
                     continue;
                 }
                 if (Workers.ContainsKey(profile.Abbreviation))
                 {
                     //There is already a worker for this region, may it be active or inactive - do not proceed
                     continue;
                 }
                 Worker worker = new Worker(Program, this, profile, Configuration, Provider);
                 Workers[profile.Abbreviation] = worker;
                 worker.Run();
             }
         }
     }
 }