Example #1
0
        private void CheckConnState()
        {
            while (true)
            {
                if (!CpldBase.ThreadFlags.ConnStatCheck)
                {
                    Thread.Sleep(5000);
                    continue;
                }

                Dispatcher.Invoke(new Action(
                                      delegate
                {
                    LoadBoardCount();
                    if (CommonControl.CheckSocketState())
                    {
                        CpldStatus.Text      = "在线";
                        ImgCpldStatus.Source = new BitmapImage(new Uri("Icon/cpldOnline.png", UriKind.RelativeOrAbsolute));
                        if (CpldPoint.Text == "未知")
                        {
                            LoadBoardCount();
                        }
                    }
                    else
                    {
                        CpldStatus.Text      = "连接中..";
                        CpldPoint.Text       = "未知";
                        ImgCpldStatus.Source = new BitmapImage(new Uri("Icon/cpldOffline.png", UriKind.RelativeOrAbsolute));
                        OpenConnection();
                    }
                }
                                      ));
                Thread.Sleep(5000);
            }
        }
Example #2
0
        private void OpenConnection()
        {
            CommonControl.OpenConnection();

            if (CommonControl.CheckSocketState())
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    CpldStatus.Text      = "在线";
                    ImgCpldStatus.Source = new BitmapImage(new Uri("Icon/cpldOnline.png", UriKind.RelativeOrAbsolute));
                    LoadBoardCount();
                }
                                             ));
            }
        }