private void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (Dispatcher.Thread != Thread.CurrentThread)
            {
                Dispatcher.BeginInvoke(new EventHandler <ElapsedEventArgs>(timer_Elapsed), sender, e);
                return;
            }

            // Update list box
            ListBox.Items.Clear();
            foreach (var p in Process.GetProcessesByName(_procName))
            {
                if (!string.IsNullOrEmpty(p.MainWindowTitle))
                {
                    ListBox.Items.Add(p.MainWindowTitle);
                }
            }

            // Check if process is running
            if (MiscFunctions.IsProcessRunning(_procName))
            {
                return;
            }

            DialogResult = true;
            Close();
        }
        internal static bool?DisplayRunningMsg(string scannerName, string procName)
        {
            if (Application.Current.Dispatcher.Thread != Thread.CurrentThread)
            {
                return
                    ((bool?)
                     Application.Current.Dispatcher.Invoke(new Func <string, string, bool?>(DisplayRunningMsg),
                                                           scannerName, procName));
            }

            if (!MiscFunctions.IsProcessRunning(procName))
            {
                return(true);
            }

            if (Settings.Default.privacyCleanerAutoSkipScanner)
            {
                MessageBox.Show(Application.Current.MainWindow,
                                $"Automatically skipping the scanning for {scannerName}...", Utils.ProductName, MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return(false);
            }

            var dlgResult = new RunningMsg(scannerName, procName);

            return(dlgResult.ShowDialog());
        }
        public void DeleteIniSection(string filePath, string searchSectionText)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            IniList.AddRange(
                MiscFunctions.GetSections(filePath)
                .Where(sectionName => !string.IsNullOrEmpty(sectionName))
                .Where(sectionName => Regex.IsMatch(sectionName, searchSectionText))
                .Select(sectionName => new IniInfo {
                FilePath = filePath, SectionName = sectionName
            }));
        }
        public void DeleteIniValue(string filePath, string searchSectionText, string searchValueNameText)
        {
            if (!File.Exists(filePath))
            {
                return;
            }

            foreach (
                var sectionName in
                MiscFunctions.GetSections(filePath)
                .Where(sectionName => !string.IsNullOrEmpty(sectionName))
                .Where(sectionName => Regex.IsMatch(sectionName, searchSectionText)))
            {
                IniList.AddRange(MiscFunctions.GetValues(filePath, sectionName)
                                 .Cast <KeyValuePair <string, string> >()
                                 .Where(kvp => Regex.IsMatch(kvp.Key, searchValueNameText))
                                 .Select(kvp => new IniInfo {
                    FilePath = filePath, SectionName = sectionName, ValueName = kvp.Key
                }));
            }
        }