//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(); } } } }
void CreateWorkers() { Workers = new List<Worker>(); foreach (var profile in ServiceConfiguration.RegionProfiles) { Worker worker = new Worker(profile, ServiceConfiguration, Provider); Workers.Add(worker); } }
public void Run() { Workers = new List<Worker>(); foreach (var login in Profile.Logins) { Worker newWorker = new Worker(Profile, login, ServiceConfiguration, this, DatabaseProvider); Workers.Add(newWorker); } AutomaticUpdateThread = new Thread(PerformAutomaticUpdates); AutomaticUpdateThread.Start(); }