ActiveRewardTimer.cs 902 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using System.Linq;
  6. using Microsoft.Extensions.Hosting;
  7. using MySystem;
  8. public class ActiveRewardTimer
  9. {
  10. public readonly static ActiveRewardTimer Instance = new ActiveRewardTimer();
  11. private ActiveRewardTimer()
  12. {
  13. }
  14. public void Start()
  15. {
  16. Thread th = new Thread(DoWorks);
  17. th.IsBackground = true;
  18. th.Start();
  19. }
  20. private void DoWorks()
  21. {
  22. while (true)
  23. {
  24. string MsgContent = RedisDbconn.Instance.RPop<string>("ActiveReward");
  25. if (!string.IsNullOrEmpty(MsgContent))
  26. {
  27. JobMqMsg job = Newtonsoft.Json.JsonConvert.DeserializeObject<JobMqMsg>(MsgContent);
  28. StatService.Instance.ActiveReward(job);
  29. }
  30. Thread.Sleep(30000);
  31. }
  32. }
  33. }