<commit_before>﻿namespace liboroc
{
    using System;
    using System.Diagnostics;

    public static class ProcessHelper
    {
        public static void ExecuteScript(string script_path, string command_line = null, bool headless = false)
        {
            if (string.IsNullOrWhiteSpace(script_path))
                return;

            using (Process process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = script_path,
                    Arguments = command_line,
                    CreateNoWindow = headless,
                    UseShellExecute = true,
                }
            })
            {
                process.Start();
                process.WaitForExit();
            }
        }

        private class QuitVisitor : ProcessObserver.IVisitor
        {
            public void Visit(Process process)
            {
                if (!process.HasExited)
                {
                    process.Kill();
                    process.WaitForExit((int)TimeSpan.FromSeconds(1).TotalMilliseconds);
                }
            }
        }

        public static void Shutdown(int pid)
        {
            ProcessObserver.Instance.Accept(new QuitVisitor(), pid);
        }

        private class BringToFrontVisitor : ProcessObserver.IVisitor
        {
            public bool Aggressive = false;

            public void Visit(Process process)
            {
                if (!process.HasExited && process.MainWindowHandle != IntPtr.Zero)
                {
                    if (NativeMethods.GetForegroundWindow() != process.MainWindowHandle)
                    {
                        NativeMethods.SwitchToThisWindow(process.MainWindowHandle, true);
                        NativeMethods.SetForegroundWindow(process.MainWindowHandle);

                        if (Aggressive)
                        {
                            NativeMethods.SetWindowPos(
                                process.MainWindowHandle,
                                NativeMethods.HWND_TOPMOST,
                                0, 0, 0, 0,
                                NativeMethods.SetWindowPosFlags.SWP_NOSIZE |
                                NativeMethods.SetWindowPosFlags.SWP_NOMOVE |
                                NativeMethods.SetWindowPosFlags.SWP_SHOWWINDOW);
                        }
                    }
                }
            }
        }

        public static void BringToFront(int pid, bool aggressive)
        {
            ProcessObserver.Instance.Accept(new BringToFrontVisitor { Aggressive = aggressive }, pid);
        }
    }
}<commit_msg>modified process helper to use ExecutorService<commit_after>﻿namespace liboroc
{
    using System;
    using System.Diagnostics;

    public static class ProcessHelper
    {
        public static void ExecuteScript(string script_path, string command_line = null, bool headless = false)
        {
            if (string.IsNullOrWhiteSpace(script_path))
                return;

            using (Process process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = script_path,
                    Arguments = command_line,
                    CreateNoWindow = headless,
                    UseShellExecute = true,
                }
            })
            {
                process.Start();
                process.WaitForExit();
            }
        }

        public static void Shutdown(int pid)
        {
            ProcessObserver.Instance.Accept((process) =>
            {
                if (!process.HasExited)
                {
                    process.Kill();
                    process.WaitForExit((int)TimeSpan.FromSeconds(1).TotalMilliseconds);
                }
            }
            , pid);
        }

        public static void BringToFront(int pid, bool aggressive)
        {
            ProcessObserver.Instance.Accept((process) =>
            {
                if (!process.HasExited && process.MainWindowHandle != IntPtr.Zero)
                {
                    if (NativeMethods.GetForegroundWindow() != process.MainWindowHandle)
                    {
                        NativeMethods.SwitchToThisWindow(process.MainWindowHandle, true);
                        NativeMethods.SetForegroundWindow(process.MainWindowHandle);

                        if (aggressive)
                        {
                            NativeMethods.SetWindowPos(
                                process.MainWindowHandle,
                                NativeMethods.HWND_TOPMOST,
                                0, 0, 0, 0,
                                NativeMethods.SetWindowPosFlags.SWP_NOSIZE |
                                NativeMethods.SetWindowPosFlags.SWP_NOMOVE |
                                NativeMethods.SetWindowPosFlags.SWP_SHOWWINDOW);
                        }
                    }
                }
            }
            , pid);
        }
    }
}
{'fraction_non_alphanumeric': 0.06599286563614744, 'fraction_numerical': 0.0019817677368212444, 'mean_word_length': 1.126843657817109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4010217', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1084, 'n_words': 197}