标签:
public void Start() { logger.Trace var iDelay= int.Parse(strDelay); time = new Timer(x => { if (Interlocked.Exchange(ref isExec,1) == 0) { try { logger.Trace ProgramTest.Start(); } catch (Exception ex) { logger.Error } finally { Interlocked.Exchange(ref isExec,0); } } },null,startDelay,1000 * 60 * iDelay); }
参考网址:https://msdn.microsoft.com/zh-cn/library/system.threading.interlocked.aspx
public static void Start() { // 判断是否有服务的线程启动 if (Thread.CurrentThread.IsThreadPoolThread) ServiceThreadId = Thread.CurrentThread.ManagedThreadId; logger.Trace("当前服务线程Id:{0}",ServiceThreadId.ToString()); dtStart = DateTime.Now; logger.Trace foreach (var a in b) { Action<T> A=new Action<T>(item => { bool flag=true;for (int i=1; i <= 100; i++) { if (!flag) break; #region 遍历添加商品信息 foreach (var c in d) { //TODO } #endregion logger.Trace } }); A.BeginInvoke(a,null,null); } CheckThreadPool(); Console.Read(); }
标签:
原文地址:http://www.cnblogs.com/singles/p/4536546.html