コード例 #1
0
 private void WorkerThread(CancellationToken token)
 {
     Task.Factory.StartNew(() =>
     {
         this.Running        = true;
         AVIReader aviReader = new AVIReader();
         try
         {
             aviReader.Open(VideoSource); // open file
             while (!cts.IsCancellationRequested)
             {
                 Bitmap bmp = aviReader.GetNextFrame();  // get next frame
                 FramesReceived++;
                 if (NewFrame != null)
                 {
                     NewFrame(this, new CameraEventArgs(bmp));
                 }
                 bmp.Dispose();  // free image
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
         aviReader.Dispose();
         aviReader    = null;
         this.Running = false;
     }, token);
 }
コード例 #2
0
        // Free resources
        private void Free()
        {
            aviReader.Dispose();
            aviReader = null;

            thread = null;

            // release events
            stopEvent.Close();
            stopEvent = null;
        }
コード例 #3
0
ファイル: VideoFileSource.cs プロジェクト: lickey10/SCTV
        // Thread entry point
        public void WorkerThread()
        {
            AVIReader aviReader = new AVIReader();

            try
            {
                // open file
                aviReader.Open(source);

                while (true)
                {
                    // start time
                    DateTime start = DateTime.Now;

                    // get next frame
                    Bitmap bmp = aviReader.GetNextFrame();

                    framesReceived++;

                    // need to stop ?
                    if (stopEvent.WaitOne(0, false))
                    {
                        break;
                    }

                    if (NewFrame != null)
                    {
                        NewFrame(this, new CameraEventArgs(bmp));
                    }

                    // free image
                    bmp.Dispose();

                    // end time
                    TimeSpan span = DateTime.Now.Subtract(start);

                    // sleep for a while

/*					int			m = (int) span.TotalMilliseconds;
 *
 *                                      if (m < 100)
 *                                              Thread.Sleep(100 - m);*/
                }
            }
            catch (Exception ex)
            {
                Tools.WriteToFile(Tools.errorFile, "WorkerThread error: " + ex.Message);
                System.Diagnostics.Debug.WriteLine("exception : " + ex.Message);
            }

            aviReader.Dispose();
            aviReader = null;
        }
コード例 #4
0
ファイル: PictureGiver.cs プロジェクト: SeryMa/FlyCatcher
 public void Dispose() => reader.Dispose();