<commit_before>﻿using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;

namespace KellyElton.ModuleHost.WindowsService
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main() {
            ServiceBase[] ServicesToRun = new ServiceBase[] {
                new ModuleHostService()
            };

            Thread appThread = new Thread( ApplicationThread );
            appThread.SetApartmentState( ApartmentState.STA );
            appThread.Start();

            if( Debugger.IsAttached ) {
                foreach(IStartable sb in ServicesToRun ) {
                    sb.Start();
                }
                while( !EndResetEvent.WaitOne( 10 ) ) {
                    if( Console.KeyAvailable ) break;
                };
                foreach(IStartable sb in ServicesToRun ) {
                    sb.Stop();
                }
                Application.ExitThread();
            } else {
                ServiceBase.Run( ServicesToRun );
            }
            appThread.Join();
        }

        private static volatile bool KeepRunning;
        private static ManualResetEvent EndResetEvent = new ManualResetEvent(false);

        static void ApplicationThread() {
            try {
                while( KeepRunning ) {
                    Application.DoEvents();
                }
            } finally {
                EndResetEvent.Set();
            }
        }
    }
}<commit_msg>Forget Application Thread<commit_after>﻿using System;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;

namespace KellyElton.ModuleHost.WindowsService
{
    static class Program
    {
        private static volatile bool KeepRunning = true;

        static void Main() {
            ServiceBase[] ServicesToRun = new ServiceBase[] {
                new ModuleHostService()
            };

            if( Debugger.IsAttached ) {
                foreach(IStartable sb in ServicesToRun ) {
                    sb.Start();
                }
                while( KeepRunning ) {
                    if( Console.KeyAvailable ) {
                        KeepRunning = false;
                        break;
                    }
                    Thread.Sleep( 10 );
                };
                foreach(IStartable sb in ServicesToRun ) {
                    sb.Stop();
                }
            } else {
                ServiceBase.Run( ServicesToRun );
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.08150711264898117, 'fraction_numerical': 0.0015378700499807767, 'mean_word_length': 1.3006189213085764, 'pattern_counts': {'":': 0, '<': 5, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '249851', 'n_tokens_mistral': 628, 'n_tokens_neox': 583, 'n_words': 138}