33 lines
976 B
C#
33 lines
976 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace cloudPrintWinAgent
|
|
{
|
|
public sealed class Worker : BackgroundService
|
|
{
|
|
private readonly ILogger<Worker> _logger;
|
|
|
|
public Worker(ILogger<Worker> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
_logger.LogInformation("WinAgent started at: {Time}", DateTimeOffset.Now);
|
|
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
// TODO: 后续放心跳、订阅任务、状态回传
|
|
_logger.LogInformation("WinAgent heartbeat tick at: {Time}", DateTimeOffset.Now);
|
|
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
|
|
}
|
|
|
|
_logger.LogInformation("WinAgent stopping at: {Time}", DateTimeOffset.Now);
|
|
}
|
|
}
|
|
}
|