You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB
C#

12 months ago
using System.Diagnostics;
using HttpClientStudy.Core.Utils;
12 months ago
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
12 months ago
Process currentProcess = Process.GetCurrentProcess();
currentProcess.EnableRaisingEvents = true;
currentProcess.Exited += (s, r) =>
{
Console.WriteLine("000000000000000000000000000000000000");
};
// <20><>ȡ IHostApplicationLifetime ʵ<><CAB5>
var applicationLifetime = app.Services.GetRequiredService<IHostApplicationLifetime>();
// ע<><D7A2>Ӧ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ر<EFBFBD><D8B1>¼<EFBFBD>
applicationLifetime.ApplicationStopping.Register(() =>
{
//<2F>ر<EFBFBD>WebApi
StartupUtility.ExitWebApiProject();
});
applicationLifetime.ApplicationStopped.Register(() => {
Console.WriteLine("xxxxxxxxxxxxxxxxxxxx");
});
// ע<><D7A2> AppDomain <20><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
AppDomain.CurrentDomain.UnhandledException += (s,e)=>
{
Console.WriteLine("<22>˳<EFBFBD>");
};
//ȷ<><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WebApi<70><69><EFBFBD><EFBFBD>
StartupUtility.StartWebApiProject();
12 months ago
app.Run();