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 AlipayPayBack2Timer : BackgroundService { protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { int timespan = 1000; await Task.Delay(timespan).ContinueWith(tsk => { DoWorks(); }); } } private void DoWorks() { string MsgContent = RedisDbconn.Instance.RPop("AlipayPayBack2"); if (!string.IsNullOrEmpty(MsgContent)) { JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject(MsgContent); AlipayPayBack2Service.Instance.Start(job); } else { Thread.Sleep(1000); } } }