コード例 #1
0
        /// <summary>
        ///     The programs entry point.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Main(string[] args)
        {
            //Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
            if (IsRunningOnMono())
            {
                var service = new MiNetService();
                service.Start();
                Console.WriteLine("RaNET running. Press <enter> to stop service.");
                Console.ReadLine();
                service.Stop();
            }
            else
            {
                HostFactory.Run(host =>
                {
                    host.Service <MiNetService>(s =>
                    {
                        s.ConstructUsing(construct => new MiNetService());
                        s.WhenStarted(service => service.Start());
                        s.WhenStopped(service => service.Stop());
                    });

                    host.RunAsLocalService();
                    host.SetDisplayName("RaNET Service");
                    host.SetDescription("RaNET Minecraft Pocket Edition server.");
                    host.SetServiceName("RaNET");
                });
            }
        }
コード例 #2
0
ファイル: MiNetService.cs プロジェクト: WilliamGao1/MiNET
        /// <summary>
        ///     The programs entry point.
        /// </summary>
        /// <param name="args">The arguments.</param>
        private static void Main(string[] args)
        {
            if (IsRunningOnMono())
            {
                var service = new MiNetService();
                service.Start();
                Console.WriteLine("MiNET runing. Press <enter> to stop service..");
                Console.ReadLine();
                service.Stop();
            }
            else
            {
                HostFactory.Run(host =>
                {
                    host.Service<MiNetService>(s =>
                    {
                        s.ConstructUsing(construct => new MiNetService());
                        s.WhenStarted(service => service.Start());
                        s.WhenStopped(service => service.Stop());
                    });

                    host.RunAsLocalService();
                    host.SetDisplayName("MiNET Service");
                    host.SetDescription("MiNET MineCraft Pocket Edition server.");
                    host.SetServiceName("MiNET");
                });
            }
        }