提交功能
This commit is contained in:
60
Program.cs
Normal file
60
Program.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ACBuildService;
|
||||
|
||||
public class Program
|
||||
{
|
||||
private static volatile Task _loopTask;
|
||||
private static volatile Task _shutDownTask;
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
App.Init();
|
||||
Test();
|
||||
await HttpService.Start();
|
||||
ExitHandle();
|
||||
_loopTask = EnterAsync();
|
||||
await _loopTask;
|
||||
}
|
||||
|
||||
private static async Task EnterAsync()
|
||||
{
|
||||
while (App.Running)
|
||||
{
|
||||
await Task.Delay(10);
|
||||
App.Update();
|
||||
App.LateUpdate();
|
||||
}
|
||||
|
||||
Log.Info("Stop");
|
||||
}
|
||||
|
||||
private static void ExitHandle()
|
||||
{
|
||||
//退出监听
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => { ServerExitConfirm(); };
|
||||
//Fetal异常监听
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => { ServerExitConfirm(); };
|
||||
//ctrl+c
|
||||
Console.CancelKeyPress += (_, _) => { ServerExitConfirm(); };
|
||||
}
|
||||
|
||||
private static void ServerExitConfirm()
|
||||
{
|
||||
Log.Info("开始执行退出程序");
|
||||
_shutDownTask = Task.Run(() =>
|
||||
{
|
||||
App.Running = false;
|
||||
_loopTask?.Wait();
|
||||
Console.WriteLine("退出完成");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
});
|
||||
_shutDownTask.Wait();
|
||||
}
|
||||
|
||||
|
||||
private static void Test()
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user