using System.Threading; using MySystem; using MySystem.OpModels; public class OperateAmountRecordService { public readonly static OperateAmountRecordService Instance = new OperateAmountRecordService(); private OperateAmountRecordService() { } public void Start() { Thread th = new Thread(DoWorks); th.IsBackground = true; th.Start(); } private void DoWorks() { while (true) { string content = RedisDbconn.Instance.RPop("OperateAmountRecordServiceQueue"); if (!string.IsNullOrEmpty(content)) { WebCMSEntities db = new WebCMSEntities(); Utils.Instance.OperateAmountChange(db,Newtonsoft.Json.JsonConvert.DeserializeObject(content)); db.Dispose(); } else { Thread.Sleep(5000); } } } }