private void WriteThread()
        {
            System.Exception error = null;

            try
            {
                while (running)
                {
                    signal.WaitOne();

                    IList <Damany.Imaging.Contracts.Portrait> portraits = null;
                    lock (this.locker)
                    {
                        if (this.portraitQueue.Count > 0)
                        {
                            portraits = this.portraitQueue.Dequeue();
                        }
                    }

                    if (portraits != null)
                    {
                        base.SavePortraits(portraits);
                        portraits.ToList().ForEach(p =>
                        {
                            if (win != null)
                            {
                                win.Dispose();
                                win = null;
                            }

                            win = new OpenCvSharp.CvWindow(p.CapturedAt.ToShortTimeString(), p.GetImage().Clone());
                            OpenCvSharp.CvWindow.WaitKey(500);
                            p.Dispose();
                        });
                    }
                }
            }
            catch (System.Exception ex)
            {
                this.faulted = true;
                error        = ex;
            }
            finally
            {
                OnStopped(new MiscUtil.EventArgs <Exception>(error));
                this.running = false;
            }
        }
        private void WriteThread()
        {
            System.Exception error = null;

            try
            {
                while (running)
                {
                    signal.WaitOne();

                    IList<Damany.Imaging.Common.Portrait> portraits = null;
                    lock (this.locker)
                    {
                        if (this.portraitQueue.Count > 0)
                        {
                            portraits = this.portraitQueue.Dequeue();
                        }
                    }

                    if (portraits != null)
                    {
                        base.SavePortraits(portraits);
                        portraits.ToList().ForEach(p =>
                        {
                            if (win != null)
                            {
                                win.Dispose();
                                win = null;
                            }

                            win = new OpenCvSharp.CvWindow(p.CapturedAt.ToShortTimeString(), p.GetIpl().Clone());
                            OpenCvSharp.CvWindow.WaitKey(500);
                            p.Dispose();
                        });
                    }

                }
            }
            catch (System.Exception ex)
            {
                this.faulted = true;
                error = ex;
            }
            finally
            {
                OnStopped(new MiscUtil.EventArgs<Exception>(error));
                this.running = false;
            }
        }