private void UpdateCounterPreferences()
        {
            List <PerformanceCounterPreference> toberemoved = new List <PerformanceCounterPreference>();

            foreach (var counter in _counters)
            {
                var pref = Configuration.Instance.PerformanceCounterPreferences.Where(p => p.Name == counter.ToString()).FirstOrDefault();

                // Remove counters no longer enabled
                if (!counter.Enabled)
                {
                    if (pref != null)
                    {
                        toberemoved.Add(pref);
                    }
                    continue;
                }

                // Make a new preference for this counter as none could be found
                if (pref == null)
                {
                    pref = new PerformanceCounterPreference();
                    Configuration.Instance.PerformanceCounterPreferences.Add(pref);
                }
                pref.Name     = counter.ToString();
                pref.Scale    = counter.Scale;
                pref.LastSeen = DateTime.UtcNow;
            }
            Configuration.Instance.PerformanceCounterPreferences.RemoveAll(p => toberemoved.Contains(p));
            CleanOldCounters();
            Configuration.Instance.Save();
        }
        private void UpdateCounterPreferences()
        {
            List<PerformanceCounterPreference> toberemoved = new List<PerformanceCounterPreference>();
            foreach (var counter in _counters)
            {
                var pref = Configuration.Instance.PerformanceCounterPreferences.Where(p => p.Name == counter.ToString()).FirstOrDefault();

                // Remove counters no longer enabled
                if (!counter.Enabled)
                {
                    if (pref != null)
                        toberemoved.Add(pref);
                    continue;
                }

                // Make a new preference for this counter as none could be found
                if (pref == null)
                {
                    pref = new PerformanceCounterPreference();
                    Configuration.Instance.PerformanceCounterPreferences.Add(pref);
                }
                pref.Name = counter.ToString();
                pref.Scale = counter.Scale;
                pref.LastSeen = DateTime.UtcNow;
            }
            Configuration.Instance.PerformanceCounterPreferences.RemoveAll(p => toberemoved.Contains(p));
            CleanOldCounters();
            Configuration.Instance.Save();
        }