using Microsoft.Extensions.Hosting; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using System.Threading; namespace Utility.Job { public class HostedService : IHostedService { private SchedulerCenter schedulerCenter; public HostedService(SchedulerCenter schedulerCenter) { this.schedulerCenter = schedulerCenter; } public async Task StartAsync(CancellationToken cancellationToken) { //开启调度器 await schedulerCenter.StartScheduleAsync(); } public Task StopAsync(CancellationToken cancellationToken) { return Task.CompletedTask; } } }