42 lines
939 B
C#
42 lines
939 B
C#
using Microsoft.Extensions.Hosting;
|
|
using Quartz;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GWMS.UI
|
|
{
|
|
public class QuartzHostedService : IHostedService
|
|
{
|
|
#region Private Fields
|
|
|
|
private readonly IScheduler _scheduler;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Public Constructors
|
|
|
|
public QuartzHostedService(IScheduler scheduler)
|
|
{
|
|
_scheduler = scheduler;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
public async Task StartAsync(CancellationToken cancellationToken)
|
|
{
|
|
await _scheduler?.Start(cancellationToken);
|
|
}
|
|
|
|
public async Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
await _scheduler?.Shutdown(cancellationToken);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |