コード例 #1
0
ファイル: Program.cs プロジェクト: campbeb/GamePipe
        static void Main(string[] args)
        {
            Console.WriteLine("Starting service...");
            var minimumEndTime = DateTime.UtcNow.AddSeconds(3);

            using (ServiceHost host = new ServiceHost(typeof(WingmanService)))
            {
                host.Open();

                Console.WriteLine("Service up and running at:");
                foreach (var ea in host.Description.Endpoints)
                {
                    Console.WriteLine(ea.Address);
                }

                while (IsGamePipeRunning() || WingmanService.HasItems() || DateTime.UtcNow < minimumEndTime)
                {
                    if (!IsSteamRunning() && WingmanService.HasItems())
                    {
                        WingmanService.ProcessHitList();
                    }
                    else
                    {
                        Thread.Sleep(500);
                    }
                }
            }

            if (WingmanService.GetRestartRequested())
            {
                Process.Start(@"steam://open/games");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: truboxl/GamePipe
        static void Main(string[] args)
        {
            var minimumEndTime = DateTime.UtcNow.AddSeconds(3);

            using (ServiceHost host = new ServiceHost(typeof(WingmanService)))
            {
                host.Open();

                Console.WriteLine("Service up and running at:");
                foreach (var ea in host.Description.Endpoints)
                {
                    Console.WriteLine(ea.Address);
                }

                while (true)
                {
                    if (WingmanService.HasItems())
                    {
                        if (!IsSteamRunning())
                        {
                            WingmanService.ProcessHitList();
                            if (WingmanService.GetRestartRequested())
                            {
                                Thread.Sleep(3000);
                                OpenSteam();
                                WingmanService.ClearRestartRequest();
                            }
                        }
                        else
                        {
                            //Monitor system utilization, try to restart steam when nobody is looking... o.O
                            if (IsSystemIdle() && !Cached_IsAnySteamAppRunning())
                            {
                                CloseSteam();
                                var timeout = DateTime.UtcNow.AddMinutes(3);
                                while (IsSteamRunning() && timeout > DateTime.UtcNow)
                                {
                                    Thread.Sleep(100);
                                }
                                if (!IsSteamRunning())
                                {
                                    WingmanService.ProcessHitList();
                                    Thread.Sleep(3000);
                                    OpenSteam();
                                }
                            }
                        }
                    }
                    else if (DateTime.UtcNow > minimumEndTime && !IsGamePipeRunning())
                    {
                        return;
                    }
                    Thread.Sleep(500);
                }
            }
        }