You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB
C#

using DS.Module.Core;
3 months ago
using Hangfire;
using Hangfire.MySql;
3 months ago
namespace DS.WMS.JobService
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
private BackgroundJobServer _server;
public Worker(ILogger<Worker> logger)
{
3 months ago
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var options = new BackgroundJobServerOptions
{
SchedulePollingInterval = TimeSpan.FromMinutes(1),
ServerName = "WorkService",
Queues = new[] { "op", "task" }
};
while (!stoppingToken.IsCancellationRequested)
{
3 months ago
try
{
_server = new BackgroundJobServer(options);
//_server = new BackgroundJobServer();
await DoWork(stoppingToken);
3 months ago
Console.WriteLine("Hangfire Server started. Press any key to exit...");
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex);
3 months ago
}
await Task.Delay(1000, stoppingToken);
}
3 months ago
}
private async Task DoWork(CancellationToken cancellationToken)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD>
await Task.CompletedTask;
}
}
}