标注了
public class Worker : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
Console.WriteLine(DateTime.Now + " long task start ...");
await Task.Delay(1000, stoppingToken);
Console.WriteLine(DateTime.Now + " long task end ...");
}
}
public override Task StopAsync(CancellationToken cancellationToken)
{
Console.WriteLine(DateTime.Now + " stop start ...");
return base.StopAsync(cancellationToken);
}
}
换成 cs 也不行 . 放一段 java 代码也不行