using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace SHARP_CLAS_UI { public partial class Form_Cim : Form { #region Field Form_Frame _Parent; CIM_Server server; CIM_Client client; Thread UI_Update_Th; delegate void UI_Update_Delegate(); bool update_check; #endregion #region Construct public Form_Cim(Form_Frame _Parent) { InitializeComponent(); this._Parent = _Parent; server = _Parent._equip.cim_server; client = _Parent._equip.cim_client; UI_Update_Th = new Thread(UI_Update_Th_Set); UI_Update_Th.Start(); } #endregion #region Form Fuction #endregion #region Function private void UI_Update_Th_Set() { while (!_Parent.IsDisposed) { Thread.Sleep(50); if (!update_check) { update_check = true; UI_Update(); } } } private void UI_Update() { if (InvokeRequired) { BeginInvoke(new UI_Update_Delegate(UI_Update)); return; } else { try { DateTime dt = DateTime.Now; lb_Cim_Server.BackColor = _Parent._equip.cim_mode == En_Cim_Mode.Online ? Color.Lime : Color.Green; TimeSpan ts = DateTime.Now - dt; } catch (Exception ex) { } finally { update_check = false; } } } #endregion } }