AForge.Robotics.Surveyor.SRV1Camera.Stop C# (CSharp) 메소드

Stop() 공개 메소드

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it to stop and then waiting for background thread's completion.

public Stop ( ) : void
리턴 void
        public void Stop( )
        {
            if ( this.IsRunning )
            {
                thread.Abort( );
                WaitForStop( );
            }
        }

Usage Example

예제 #1
0
        /// <summary>
        /// Disconnect from SRV-1 Blackfin robot.
        /// </summary>
        ///
        /// <remarks><para>The method disconnects from SRV-1 robot making all other methods
        /// unavailable (except <see cref="Connect"/> method). In the case if user
        /// obtained instance of camera using <see cref="GetCamera"/> method, the video will
        /// be stopped automatically (and those <see cref="SRV1Camera"/> instances should be discarded).
        /// </para></remarks>
        ///
        public void Disconnect()
        {
            lock (sync)
            {
                if (thread != null)
                {
                    // signal camera to stop
                    if (camera != null)
                    {
                        camera.SignalToStop();
                    }

                    // signal worker thread to stop
                    stopEvent.Set();
                    requestIsAvailable.Set();
                    replyIsAvailable.Set();

                    // finilze the camera
                    if (camera != null)
                    {
                        // wait for aroung 250 ms
                        for (var i = 0; (i < 5) && (camera.IsRunning); i++)
                        {
                            System.Threading.Thread.Sleep(50);
                        }
                        // abort camera if it can not be stopped
                        if (camera.IsRunning)
                        {
                            camera.Stop();
                        }
                        camera = null;
                    }

                    // wait for aroung 1 s
                    for (var i = 0; (i < 20) && (thread.Join(0) == false); i++)
                    {
                        System.Threading.Thread.Sleep(50);
                    }
                    // abort thread if it can not be stopped
                    if (thread.Join(0) == false)
                    {
                        thread.Abort();
                    }

                    thread = null;

                    // release events
                    stopEvent.Close();
                    stopEvent = null;

                    requestIsAvailable.Close();
                    requestIsAvailable = null;

                    replyIsAvailable.Close();
                    replyIsAvailable = null;
                }

                if (socket != null)
                {
                    if (socket.Connected)
                    {
                        socket.Disconnect(false);
                    }
                    socket.Close();
                    socket   = null;
                    endPoint = null;
                }
            }
        }
All Usage Examples Of AForge.Robotics.Surveyor.SRV1Camera::Stop