using Microsoft.AspNetCore.Builder;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace WIDESEA_Core.Extensions
|
{
|
public static class ApplicationSetup
|
{
|
/// <summary>
|
/// 配置应用程序生命周期事件
|
/// </summary>
|
/// <param name="app">Web应用程序实例</param>
|
/// <remarks>
|
/// 在应用程序启动时设置App.IsRun为true,在停止时设置为false
|
/// </remarks>
|
public static void UseApplicationSetup(this WebApplication app)
|
{
|
app.Lifetime.ApplicationStarted.Register(() =>
|
{
|
App.IsRun = true;
|
});
|
|
app.Lifetime.ApplicationStopped.Register(() =>
|
{
|
App.IsRun = false;
|
|
//清除日志
|
//Log.CloseAndFlush();
|
});
|
}
|
}
|
}
|