Exemplo n.º 1
0
        static void Main(string[] args)
        {
            globalConfig = ConfigFile.Create("config.ini");
            sharedConfig = ConfigFile.Create("shared.ini");

            string systemLockKey = globalConfig.GetString("System", "MutexKey");
            Mutex  systemLock    = new Mutex(false, systemLockKey);

            if (!systemLock.WaitOne(TimeSpan.Zero, true))
            {
                return;
            }

            Log.ShowDate     = true; //show the date of when logs happen
            Log.ShowThreadID = true; //show the thread id that this message is from

            RPCManager.Create(".");

            CommandExecuter commandExecuter = new CommandExecuter();

            commandExecuter.Execute(args);

            Thread keyboardInterceptorThread = new Thread(SetupKeyboardInterceptor);

            keyboardInterceptorThread.Start();

            scheduler = new Core.Tasks.TaskScheduler();

            //Start the installation task.
            InstallationTask inst = new InstallationTask();

            inst.Run();

            //Schedule the frontend to launch in 30 seconds.
            scheduler.Schedule(DateTime.Now.AddSeconds(3), new FrontendLauncherTask());

            Thread readInThread = new Thread(ReadIn);

            readInThread.Start();

            while (bRunning)
            {
                Thread.Sleep(10000);
            }

            readInSafeAccess.WaitOne(Timeout.InfiniteTimeSpan, true);
            readInThread.Abort();
            readInSafeAccess.ReleaseMutex();

            scheduler.Shutdown();
            scheduler.WaitForShutdownComplete();

            globalConfig.Save();

            systemLock.ReleaseMutex();
        }