init: 初始框架
This commit is contained in:
32
Worker.cs
Normal file
32
Worker.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user