<commit_before>﻿using Lego.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Shapes;

namespace Lego
{
    class LgProcessManager
    {
        /// <summary>
        /// Move and resize the window to the current values
        /// </summary>
        /// <param name="window"></param>
        public static Boolean Reposition(LgWindow window)
        {
            IntPtr hande = window.Process.WinProcess.MainWindowHandle;
            if (hande == IntPtr.Zero) return false;
            return MoveWindow(hande, window.TopLeft.X, window.TopLeft.Y, window.Size.Width, window.Size.Height, true);
        }

        /// <summary>
        /// Starts process and sets the handler to the object
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        public static Boolean Start(LgProcess process)
        {
            try
            {
                Process p = Process.Start(process.FullPath, process.Arguments);
                
                // wait a little in order for the handler to be assigned
                p.WaitForInputIdle();
                process.WinProcess = p;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return process.WinProcess != null && process.WinProcess.Responding;
        }

        public static Boolean Stop(LgProcess process)
        {
            Process p = process.WinProcess;

            try<commit_msg>[FIX] refresh process before reading exit flag<commit_after>﻿using Lego.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Shapes;

namespace Lego
{
    class LgProcessManager
    {
        /// <summary>
        /// Move and resize the window to the current values
        /// </summary>
        /// <param name="window"></param>
        public static Boolean Reposition(LgWindow window)
        {
            IntPtr hande = window.Process.WinProcess.MainWindowHandle;
            if (hande == IntPtr.Zero) return false;
            return MoveWindow(hande, window.TopLeft.X, window.TopLeft.Y, window.Size.Width, window.Size.Height, true);
        }

        /// <summary>
        /// Starts process and sets the handler to the object
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        public static Boolean Start(LgProcess process)
        {
            try
            {
                Process p = Process.Start(process.FullPath, process.Arguments);
                
                // wait a little in order for the handler to be assigned
                p.WaitForInputIdle();
                process.WinProcess = p;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return process.WinProcess != null && process.WinProcess.Responding;
        }

        public static Boolean Stop(LgProcess process)
        {
            Process p = process.WinProcess;
            p.Refresh();

            try
{'fraction_non_alphanumeric': 0.09905100830367734, 'fraction_numerical': 0.0, 'mean_word_length': 1.7670221493027072, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3708580', 'n_tokens_mistral': 865, 'n_tokens_neox': 845, 'n_words': 230}