CgwMonitorManage.Tiandy.TiandyVideoMonitor.LoaderThread C# (CSharp) Méthode

LoaderThread() private méthode

监控平台加载器,轮询加载,直到成功
private LoaderThread ( Object mediaServerIdObj ) : void
mediaServerIdObj Object
Résultat void
        private void LoaderThread(Object mediaServerIdObj)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: TiandyVideoMonitor.LoadTiandyMonitorThread().");
            try
            {
                bool loadResult = false;
                string mediaServerId = mediaServerIdObj as string;
                while (!loadResult)
                {
                    this.GetAllCamerasTimer(null, null);
                    if (this.cameraOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                    {
                        try
                        {
                            loadResult = true;
                            this.sdkClient.SdkMediaServer = null;

                            //用户没有指定流媒体服务器,预览视频时,采用摄像头所连接的服务器。
                            if (!string.IsNullOrEmpty(mediaServerId))
                            {
                                if (this.mediaServerDictionary.ContainsKey(mediaServerId))
                                {
                                    this.sdkClient.SdkMediaServer = this.mediaServerDictionary[mediaServerId];
                                }
                                else
                                {
                                    //流媒体服务器id配置错误,Id不存在
                                    logEx.Error("Load Tiandy monitor failed.Media server id is not found.MediaServerId:{0}", mediaServerId);
                                    loadResult = false;
                                }
                            }

                            if (loadResult)
                            {
                                //设置回调函数到SDK
                                this.sdkClient.SetDataCallBackFunc(TiandyRealDataCallbackFunc);
                            }

                        }
                        finally
                        {
                            this.cameraOperateLock.ExitReadLock();
                        }
                    }

                    if (!loadResult)
                    {
                        loadResult = false;
                        Thread.Sleep(CgwConst.RELOAD_MONITOR_WAIT_TIME);
                        continue;
                    }

                    if (!this.sdkClient.Load(this.monitorId))
                    {
                        logEx.Error("Load video monitor failed.Monitor id:{0}.", this.monitorId);
                        loadResult = false;
                        Thread.Sleep(CgwConst.RELOAD_MONITOR_WAIT_TIME);
                        continue;
                    }

                    //启动定时器
                    this.updateCameraTimer.Start();
                    loadResult = true;
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error("LoaderThread catch exception:{0}", ex.Message);
            }
            logEx.Trace("Exit: TiandyVideoMonitor.LoadTiandyMonitorThread().");
        }