コード例 #1
0
        private bool InnerInitialize()
        {
            if (IsInitialized2)
            {
                return(true);
            }

            CameraDeviceManager cameraDeviceManager = new CameraDeviceManager();

            Task.Run((() => { while (!_isRefreshStop)
                              {
                                  RefreshDevice(cameraDeviceManager); Thread.Sleep(1000);
                              }
                      }));

            return(true);
        }
コード例 #2
0
        /// <summary>
        ///  刷新设备状态
        /// </summary>
        public void RefreshDevice(CameraDeviceManager cameraDeviceManager)
        {
            //刷新设备的连接状态
            bool isChanged = cameraDeviceManager.DetectState();

            if (isChanged)
            {
                //用界面线程来对_currentCameraDevice进行设置,防止设置对_currentCameraDevice设置时的多线程问题
                AppThread.Instance.Invoke(() =>
                {
                    if (cameraDeviceManager.DefaultCameraDevice != null)
                    {
                        _currentCameraDevice = cameraDeviceManager.DefaultCameraDevice;
                        Start();
                    }
                    else
                    {
                        Stop();
                        _currentCameraDevice = null;
                    }
                });
            }
        }