static void AccountsChanged(object sender, EventArgs e) { var contains = schedulers.Keys; var accounts = AccountStorage.Accounts; var newbies = accounts.Except(contains); var olds = contains.Except(accounts); if (newbies.Count() > 0) { newbies.ForEach(i => { var item = new AccountScheduler(i); schedulers.AddOrUpdate(i, item); item.StartSchedule(); }); } if (olds.Count() > 0) { olds.ForEach(i => { var item = schedulers[i]; schedulers.Remove(i); item.StopSchedule(); }); } OnSchedulerUpdated(EventArgs.Empty); }
static void AccountsChanged(object sender, EventArgs e) { var contains = schedulers.Keys; var accounts = AccountStorage.Accounts; var newbies = accounts.Except(contains); var olds = contains.Except(accounts); if (newbies.Count() > 0) newbies.ForEach(i => { var item = new AccountScheduler(i); schedulers.AddOrUpdate(i, item); item.StartSchedule(); }); if (olds.Count() > 0) olds.ForEach(i => { var item = schedulers[i]; schedulers.Remove(i); item.StopSchedule(); }); OnSchedulerUpdated(EventArgs.Empty); }