using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Hosting; using Volo.Abp; namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent; public class MesAgentHostedService : IHostedService { private readonly IAbpApplicationWithExternalServiceProvider _application; private readonly IServiceProvider _serviceProvider; private readonly MesAgentService _agentService; public MesAgentHostedService( IAbpApplicationWithExternalServiceProvider application, IServiceProvider serviceProvider, MesAgentService agentService) { _application = application; _serviceProvider = serviceProvider; _agentService = agentService; } public Task StartAsync(CancellationToken cancellationToken) { _application.Initialize(_serviceProvider); _agentService.Start(); return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) { _application.Shutdown(); return Task.CompletedTask; } }