using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Hosting; public class TradeService : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { int timespan = 50; await Task.Delay(timespan).ContinueWith(tsk => { // MySystem.ProfitHelper.Instance.StartListenTradeDo(); }); } } }