Beispiel #1
0
        /// <summary>
        /// Start the device for a frame grab, wait a bit and then return the result.
        /// This method MUST raise a CameraThumbnailProduced event, even in case of error.
        /// </summary>
        public void Run(object data)
        {
            Thread.CurrentThread.Name = string.Format("{0} thumbnailer", summary.Alias);
            log.DebugFormat("Starting {0} for thumbnail.", summary.Alias);

            if (device == null)
            {
                if (CameraThumbnailProduced != null)
                {
                    CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, null, imageDescriptor, true, false));
                }

                return;
            }

            device.NewFrame         += Device_NewFrame;
            device.VideoSourceError += Device_VideoSourceError;

            device.Start();

            waitHandle.WaitOne(timeout, false);

            device.NewFrame         -= Device_NewFrame;
            device.VideoSourceError -= Device_VideoSourceError;

            if (CameraThumbnailProduced != null)
            {
                CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, image, imageDescriptor, hadError, cancelled));
            }

            device.SignalToStop();

            // TODO: wait for a bit then kill the thread.
            //device.WaitForStop();
        }
Beispiel #2
0
        /// <summary>
        /// Start the device for a frame grab, wait a bit and then return the result.
        /// This method MUST raise a CameraThumbnailProduced event, even in case of error.
        /// </summary>
        public void Run(object data)
        {
            log.DebugFormat("Starting {0} for thumbnail.", summary.Alias);

            if (device == null)
            {
                if (CameraThumbnailProduced != null)
                {
                    CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, null, imageDescriptor, true, false));
                }

                return;
            }

            device.NewFrame         += Device_NewFrame;
            device.VideoSourceError += Device_VideoSourceError;

            device.Start();

            waitHandle.WaitOne(timeout, false);

            lock (locker)
            {
                if (!cancelled)
                {
                    device.NewFrame         -= Device_NewFrame;
                    device.VideoSourceError -= Device_VideoSourceError;
                    device.SignalToStop();
                }
            }

            if (CameraThumbnailProduced != null)
            {
                CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, image, imageDescriptor, hadError, cancelled));
            }
        }