コード例 #1
0
 void process_ResultFound(object sender, ProcessArgs e)
 {
     txtCode.Dispatcher.Invoke(new Action(delegate()
     {
         txtCode.Text = e.Result;
         // camControl.SelectedDevice.SignalToStop();
     }));
 }
コード例 #2
0
        /// Starts this instance.
        public void Start()
        {
            this.Run = true;

            ThreadStart start = new ThreadStart(delegate
            {
                while (this.Run)
                {
                    Monitor.Enter(this);
                    while (this.newBitmap == false)
                    {
                        Monitor.Wait(this, 1000);
                    }
                    using (Bitmap bitmap = (Bitmap)this.CurrentBitmap.Clone())
                    {
                        Monitor.Exit(this);
                        var result = this.Process(bitmap);
                        if (!string.IsNullOrWhiteSpace(result))
                        {
                            if (this.ResultFound != null)
                            {
                                ProcessArgs args = new ProcessArgs() { Result = result };
                                this.ResultFound(this, args);
                              //  this.Run = false;
                            }
                       }
                    }

                    // get a new bitmap to evaluate.
                    this.newBitmap = false;
                }
            });

            Thread t = new Thread(start);
            t.Start();
        }