public void WorkProcess() { try { TimeSpan tsTimeout = TimeSpan.FromSeconds(Convert.ToDouble(transactionTimeout * batchSize)); var bll = new RunQueueAsyn(); while (true) { TimeSpan datetimeStarting = new TimeSpan(DateTime.Now.Ticks); double elapsedTime = 0; var list = new List <RunQueueInfo>(); for (int j = 0; j < batchSize; j++) { try { if ((elapsedTime + queueTimeout + transactionTimeout) < tsTimeout.TotalSeconds) { list.Add(bll.ReceiveFromQueue(queueTimeout)); } else { j = batchSize; } elapsedTime = new TimeSpan(DateTime.Now.Ticks).TotalSeconds - datetimeStarting.TotalSeconds; } catch (TimeoutException) { j = batchSize; } } if (list.Count > 0) { foreach (var model in list) { if (model.RunType == EnumData.EnumRunQueue.BaiduMapRestApi.ToString()) { DoBaiduMapRestApi(model); } } } } } catch (Exception ex) { new CustomException(string.Format("来自{0}异常:{1}", "AfdRunQueue", ex.Message), ex); } }
public void WorkProcess() { try { TimeSpan tsTimeout = TimeSpan.FromSeconds(Convert.ToDouble(transactionTimeout * batchSize)); var bll = new RunQueueAsyn(); var taskBll = new DoTask(); while (true) { TimeSpan datetimeStarting = new TimeSpan(DateTime.Now.Ticks); double elapsedTime = 0; var list = new List <RunQueueInfo>(); for (int j = 0; j < batchSize; j++) { try { if ((elapsedTime + queueTimeout + transactionTimeout) < tsTimeout.TotalSeconds) { list.Add(bll.ReceiveFromQueue(queueTimeout)); } else { j = batchSize; } elapsedTime = new TimeSpan(DateTime.Now.Ticks).TotalSeconds - datetimeStarting.TotalSeconds; } catch (TimeoutException) { j = batchSize; } } if (list.Count > 0) { taskBll.DoRunQueue(list); } } } catch (Exception ex) { new CustomException(string.Format("来自{0}异常:{1}", "RunQueue", ex.Message), ex); } }