wxr
2023-09-06 fdbcb1f7463cb766f90bd29dd715485ba9d88524
HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs
@@ -6,13 +6,93 @@
{
    public partial class RoomPage
    {
        System.Threading.Thread updateUiThread;
        object lockObj = new object();
        /// <summary>
        /// 更新功能状态
        /// </summary>
        /// <param name="function"></param>
        public static void UpdataStates(Function function)
        {
            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room);
            try
            {
                if (bodyView == null)
                {
                    return;
                }
                //if (SPK.LightSpkList().Contains(function.spk))
                //{
                //    {
                //        var localFunction = FunctionList.List.GetLightList().Find((obj) => obj.sid == function.sid);
                //        {
                //            if (localFunction != null)
                //            {
                //                if (bodyView.updateUiThread == null)
                //                {
                //                    bodyView.updateUiThread = new System.Threading.Thread(() =>
                //                    {
                //                        lock (bodyView.lockObj)
                //                        {
                //                            try
                //                            {
                //                                while (true)
                //                                {
                //                                    try
                //                                    {
                //                                        System.Threading.Thread.Sleep(1500);
                //                                        if (bodyView == null)
                //                                        {
                //                                            return;
                //                                        }
                //                                        if (bodyView.updateUiThread == null)
                //                                        {
                //                                            return;
                //                                        }
                //                                        if (DateTime.Now.AddMilliseconds(-1500) > localFunction.updateTime)
                //                                        {
                //                                            MainPage.Log("没有新数据,更新UI");
                //                                            break;
                //                                        }
                //                                        else
                //                                        {
                //                                            MainPage.Log("有新数据,继续等待");
                //                                        }
                //                                    }
                //                                    catch (Exception ex)
                //                                    {
                //                                        MainPage.Log("线程异常:" + ex.Message);
                //                                    }
                //                                }
                //                                new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView, room);
                //                            }
                //                            catch (Exception ex)
                //                            {
                //                                MainPage.Log("FunctionPage UpdateStates error 2 :" + ex.Message);
                //                            }
                //                            finally
                //                            {
                //                                //bodyView.updateUiThread = null;
                //                            }
                //                        }
                //                    });
                //                    bodyView.updateUiThread.IsBackground = true;
                //                    bodyView.updateUiThread.Start();
                //                }
                //            }
                //        }
                //    }
                //}
                //else
                {
                    new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room);
                }
            }
            catch (Exception ex)
            {
                MainPage.Log("FunctionPage UpdateStates error " + ex.Message);
            }
        }
        public static void UpdataOnline(Function function)
        {