private void _StartPingTask() { Console.WriteLine("_StartPingTask"); if (_pingThread != null) { return; } _pingARE = new System.Threading.AutoResetEvent(false); _pingThread = new System.Threading.Thread(() => { while (true) { try { var pingresult = Ruanal.Core.ApiSdk.SystemApi.MasterNodePing( diswork.ToList().Select(x => new int[] { x.TaskId, x.TaskVersion }).ToList() ); if (pingresult.code > 0 && pingresult.data.HasCmd > 0) { taskRouter.Router(); } } catch (Exception ex) { } _pingARE.WaitOne(TimeSpan.FromSeconds(_PingSeconds)); } }); _pingThread.IsBackground = true; _pingThread.Start(); }
private void _StartPingTask() { if (_pingThread != null) { return; } _pingARE = new System.Threading.AutoResetEvent(false); _pingThread = new System.Threading.Thread(() => { while (true) { try { var pingresult = Ruanal.Core.ApiSdk.SystemApi.WorkNodePing( serviceItems.ToList().Select(x => new int[] { x.TaskId, x.TaskVersion }).ToList(), serviceItems.ToList().Where(x => x.JobType == 1).Select(x => new int[] { x.TaskId, x.GetFreeCount() }).ToList() ); if (pingresult.code > 0 && pingresult.data.HasCmd > 0) { _pingARE.Reset(); System.Threading.ThreadPool.QueueUserWorkItem(x => { try { taskRouter.Router(); } catch (Exception) { } }); } } catch (Exception ex) { RLib.WatchLog.Loger.Error("Ping", ex); } _pingARE.WaitOne(TimeSpan.FromSeconds(_PingSeconds)); //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(_PingSeconds)); } }); _pingThread.IsBackground = true; _pingThread.Start(); }