This commit is contained in:
Putoo
2026-07-07 18:43:01 +08:00
parent 7f29fd46b8
commit 037e845622
37 changed files with 854 additions and 106 deletions

View File

@@ -0,0 +1,25 @@
namespace Application.Web;
public class AppBackgroundService:BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
try
{
Console.WriteLine("应用启动完成,开始执行初始化后台任务");
// ========== 你要执行的启动方法写在这里 ==========
var jobService = App.GetService<IGameAutoJobService>();
await jobService.StartJob();
// ==========================================
Console.WriteLine("启动初始化任务执行完成");
// 如果只需要执行一次直接退出如果是常驻定时任务就写while循环
return;
}
catch (Exception ex)
{
Console.WriteLine("启动后台任务执行异常");
}
}
}