.NET5 启动WebApi服务完成事件
参考代码:
C# 全选
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLife)
{
Console.WriteLine("Configure...");
//注册服务启动完成事件
appLife.ApplicationStarted.Register(() =>
{
Console.WriteLine("/***************************************************/");
Console.WriteLine("Server start successfully.");
Console.WriteLine("/***************************************************/");
});
appLife.ApplicationStopping.Register(() =>
{
Console.WriteLine("Server Stopping...");
});
appLife.ApplicationStopped.Register(() =>
{
Console.WriteLine("Server Stopped.");
});
// 省略....
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网