/// <summary> /// 应用程序的主入口点。 /// </summary> static async Task Main(string[] args) { if (args.Contains("--console")) { var serverBootStrap = new ServerBootStrap(); serverBootStrap.Start(); Console.ReadKey(); await serverBootStrap.StopAsync(); } else if (args.Contains("--service")) { var servicesToRun = new ServiceBase[] { new PortProxyService(), }; ServiceBase.Run(servicesToRun); } else { if (Environment.OSVersion.Version.Major >= 6) { SetProcessDPIAware(); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new InstallService().ShowDialog(); } }
static void Main() { var bootStrap = new ServerBootStrap(); AppDomain.CurrentDomain.ProcessExit += (sender, args) => { bootStrap.StopAsync().Wait(); }; bootStrap.Start(); while (true) { Thread.Sleep(100); } }
public PortProxyService() { InitializeComponent(); _serverBootStrap = new ServerBootStrap(); }