コード例 #1
0
        // Ensure the camera is stopped
        public void Remove(VsCamera camera)
        {
            // lock
            Monitor.Enter(this);

            try
            {
                int n = InnerList.Count;
                for (int i = 0; i < n; i++)
                {
                    if (InnerList[i] == camera)
                    {
                        if (camera.Running)
                        {
                            camera.Stop();
                        }
                        camera.CloseVideoSource();
                        camera.CloseAnalyserSource();
                        camera.CloseEncoderSource();
                        InnerList.RemoveAt(i);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }
        }
コード例 #2
0
        // Thread entry point
        private void WorkerThread()
        {
            while (!stopEvent.WaitOne(0, true))
            {
                // lock
                Monitor.Enter(this);

                try
                {
                    int n = InnerList.Count;

                    // check each camera
                    for (int i = 0; i < n; i++)
                    {
                        VsCamera camera = (VsCamera)InnerList[i];

                        if (!camera.Running)
                        {
                            camera.CloseVideoSource();
                            camera.CloseAnalyserSource();
                            camera.CloseEncoderSource();
                            InnerList.RemoveAt(i);
                            i--;
                            n--;
                        }
                    }
                }
                catch (Exception err)
                {
                    logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
                }
                finally
                {
                    // unlock
                    Monitor.Exit(this);
                }

                // sleep for a while
                Thread.Sleep(300);
            }

            try
            {
                // Exiting, so kill'em all
                foreach (VsCamera camera in InnerList)
                {
                    camera.Stop();
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
        }
コード例 #3
0
		// Ensure the camera is stopped
		public void Remove(VsCamera camera)
		{
			// lock
			Monitor.Enter(this);

            try
            {
                int n = InnerList.Count;
                for (int i = 0; i < n; i++)
                {
                    if (InnerList[i] == camera)
                    {
                        if (camera.Running)
                            camera.Stop();
                        camera.CloseVideoSource();
                        camera.CloseAnalyserSource();
                        camera.CloseEncoderSource();
                        InnerList.RemoveAt(i);
                        break;
                    }
                }
            }
            catch (Exception err)
            {
                logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);;
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }
		}