using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using System.Linq; using Microsoft.Extensions.Hosting; using MySystem; using MySystem.PxcModels; using Library; using LitJson; public class SycnSpTimer : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { int timespan = 100; await Task.Delay(timespan).ContinueWith(tsk => { DoWorks(); }); } } private void DoWorks() { string MsgContent = RedisDbconn.Instance.RPop("SycnSpServer"); if (!string.IsNullOrEmpty(MsgContent)) { JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject(MsgContent); SycnSpService.Instance.Start(job); } } }