示例#1
0
 protected override ExecuteResult <int> DoCommit(int retry = 0)
 {
     if (Committed)
     {
         return(ExecuteResult <int> .CreateFaile(0, "已提交"));
     }
     try
     {
         var result = this.Context.SaveChanges();
         this.Committed = true;
         return(ExecuteResult <int> .CreateSuccess(result, "提交成功"));
     }
     catch (Exception ex)
     {
         YmatouLoggingService.Warning("执行失败 {0},重试 {1} 次", ex.ToString(), retry);
         //重试
         //return RetryUtility.RetryAction2(() =>
         // {
         //     var result = this.Context.SaveChanges();
         //     this.Committed = true;
         //     return Tuple.Create<ExecuteResult<int>, bool>(new ExecuteResult<int>(true, null, result), result > 0);
         // }, retry, 3000).Item1;
         //RetryUtility.RetryAction2(() => System.Tuple.Create<ExecuteResult<int>, bool>(new ExecuteResult<int>(true, null, 0), true), 1000);
         return(new ExecuteResult <int>(true, null, 0));
     }
 }
示例#2
0
 public void Start()
 {
     if (init || PQStatus == Status.RunIng)
     {
         YmatouLoggingService.Warning("PQ 队列已启动");
         return;
     }
     if (thList.Count <= 0)
     {
         lock (thList)
         {
             if (thList.Count <= 0)
             {
                 YmatouLoggingService.Debug("启动队列开始 {0}", pqSetting.QName);
                 //thList = new List<Thread>();
                 for (var i = 0; i < pqSetting.ThreadCount; i++)
                 {
                     var th = new Thread(Consumer)
                     {
                         IsBackground = true, Name = "PQ_" + i
                     };
                     th.Start();
                     thList.Add(th);
                 }
                 init     = true;
                 PQStatus = Status.RunIng;
                 YmatouLoggingService.Debug("启动队列结束 {0}", pqSetting.QName);
             }
         }
     }
 }