using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using System.Linq; using Microsoft.Extensions.Hosting; using MySystem; public class ActiveRewardTimer { public readonly static ActiveRewardTimer Instance = new ActiveRewardTimer(); private ActiveRewardTimer() { } public void Start() { Thread th = new Thread(DoWorks); th.IsBackground = true; th.Start(); } private void DoWorks() { while (true) { string MsgContent = RedisDbconn.Instance.RPop("ActiveReward"); if (!string.IsNullOrEmpty(MsgContent)) { JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject(MsgContent); StatService.Instance.ActiveReward(job); } Thread.Sleep(30000); } } }