public void StartStopCarrier(uint carrierid, bool isstart) { if (Monitor.TryEnter(_obj, TimeSpan.FromSeconds(2))) { try { CarrierTask task = DevList.Find(c => c.ID == carrierid); if (task != null) { if (isstart) { if (!task.IsEnable) { task.SetEnable(isstart); } task.Start(); } else { if (task.IsEnable) { task.SetEnable(isstart); } task.Stop(); PubMaster.Warn.RemoveDevWarn((ushort)task.ID); } } } finally { Monitor.Exit(_obj); } } }
public void Start() { List <Device> carriers = PubMaster.Device.GetDeviceList(DeviceTypeE.运输车); foreach (Device dev in carriers) { CarrierTask task = new CarrierTask(); task.Device = dev; task.Start(); DevList.Add(task); } if (_mRefresh == null || !_mRefresh.IsAlive || _mRefresh.ThreadState == ThreadState.Aborted) { _mRefresh = new Thread(Refresh) { IsBackground = true }; } _mRefresh.Start(); }