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