Files
tnb.server/WarehouseMgr/Tnb.WarehouseMgr/ConditionalBackgroundService.cs
2023-08-04 11:26:08 +08:00

31 lines
847 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
namespace Tnb.WarehouseMgr
{
public class ConditionalBackgroundService : IHostedService
{
private readonly IHostedService _backgroundService;
//private readonly Func<bool> _condition;
public ConditionalBackgroundService(IHostedService backgroundService)
{
_backgroundService = backgroundService;
}
public async Task StartAsync(CancellationToken cancellationToken)
{
await _backgroundService.StartAsync(cancellationToken);
}
public async Task StopAsync(CancellationToken cancellationToken)
{
await _backgroundService.StopAsync(cancellationToken);
}
}
}