2025-06-12 17:55:19 +08:00
|
|
|
|
using JiShe.ServicePro.Core;
|
2025-07-24 15:29:12 +08:00
|
|
|
|
using JiShe.ServicePro.DeviceManagement.DeviceInfos;
|
2025-06-12 17:55:19 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
2025-11-07 11:48:22 +08:00
|
|
|
|
namespace JiShe.IoT.Jobs
|
2025-06-12 17:55:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2025-11-07 11:48:22 +08:00
|
|
|
|
/// GCCollect 定时手动回收
|
2025-06-12 17:55:19 +08:00
|
|
|
|
/// </summary>
|
2025-11-07 11:48:22 +08:00
|
|
|
|
public class GCCollectJob : SystemBackGroundWorkService
|
2025-06-12 17:55:19 +08:00
|
|
|
|
{
|
2025-11-07 11:48:22 +08:00
|
|
|
|
private readonly ILogger<GCCollectJob> _logger;
|
|
|
|
|
|
public GCCollectJob(ILogger<GCCollectJob> logger) : base(logger)
|
2025-06-12 17:55:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 定时执行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected override Task DoWorkAsync(CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
2025-11-07 11:48:22 +08:00
|
|
|
|
CommonHelper.GCCollectHandler();
|
2025-11-19 10:45:48 +08:00
|
|
|
|
_logger.LogWarning("主动执行GC回收");
|
2025-11-07 11:48:22 +08:00
|
|
|
|
return Task.CompletedTask;
|
2025-06-12 17:55:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override TimeSpan GetInterval()
|
|
|
|
|
|
{
|
2025-11-19 10:45:48 +08:00
|
|
|
|
return TimeSpan.FromMinutes(3);
|
2025-06-12 17:55:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|