Exemple #1
0
        static void Main(string[] args)
        {
            ProgramLifetime.InitialiseUnhandledExceptionHandling();
            ProgramLifetime.PrepassCommandLineArgs(args);

            ApplicationInformation.SetHeadless(ProgramLifetime.Headless);
            if (!ProgramLifetime.Headless)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
            }

            InitialiseClassFactory();

            if (ProgramLifetime.Headless)
            {
                VirtualRadar.Interop.Console.ShowConsole();
            }
            if (args.Contains("-showConfigFolder"))
            {
                ShowConfigurationFolder();
            }

            ProgramLifetime.InitialiseManagers();
            ProgramLifetime.LoadPlugins();
            ProgramLifetime.RegisterPlugins();
            ProgramLifetime.SingleInstanceStart(args);

            // Calling Environment.Exit rather than falling off the end of Main will ensure that all threads get shut down
            Environment.Exit(0);
        }
Exemple #2
0
        /// <summary>
        /// The Virtual Radar Server main thread when running as a service.
        /// </summary>
        /// <param name="state"></param>
        private void ServiceThread(object state)
        {
            try {
                var args = (string[])state;

                ProgramLifetime.InitialiseUnhandledExceptionHandling();
                ProgramLifetime.PrepassCommandLineArgs(args);
                ProgramLifetime.Headless = true;

                ApplicationInformation.SetHeadless(ProgramLifetime.Headless);

                InitialiseClassFactory();

                ProgramLifetime.InitialiseManagers();
                ProgramLifetime.LoadPlugins();
                ProgramLifetime.RegisterPlugins();
                ProgramLifetime.SingleInstanceStart(args);
            } catch (ThreadAbortException) {
                ;
            } catch (Exception ex) {
                try {
                    var log = Factory.ResolveSingleton <ILog>();
                    log.WriteLine("Caught exception in ServiceThread: {0}", ex);
                } catch {
                    ;
                }

                Stop();
            }
        }