.NetCore中的IHostedService

 

【5min+】后台任务的积木。.NetCore中的IHostedService-腾讯云开发者社区-腾讯云 (tencent.com)

原理 

_hostedServices = Services.GetService<IEnumerable<IHostedService>>();

foreach (var hostedService in _hostedServices)
{
    // Fire IHostedService.Start
    await hostedService.StartAsync(combinedCancellationToken).ConfigureAwait(false);
}

  

 

 

 

posted on 2024-08-08 11:55  是水饺不是水饺  阅读(5)  评论(0)    收藏  举报

导航