title: Digital Personna SDK Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on
body: <p>i was using Digital persona SDK for this exercise when i try to close the form it throws</p>
  
  <blockquote>
    <p>Cross-thread operation not valid: Control accessed from a thread other
    than the thread it was created on</p>
  </blockquote>
  
  <p>this code was used to login </p>
  
  <pre><code>SqlConnection dataBaseConnection = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=DemoDB;Integrated Security=True");
          public delegate void OnTemplateEventHandler(DPFP.Template template);
  
          Timer closeTimer = new Timer();
          DPFP.Capture.Capture Capturer = new DPFP.Capture.Capture();
          public login()
          {
              InitializeComponent();
              closeTimer.Tick+=new EventHandler(closeTimer_Tick);
          }
  
          private DPFP.Template Template;
          private DPFP.Verification.Verification Verificator;
          int time = 0;
  
          protected virtual void Init()
          {
              Capturer = new DPFP.Capture.Capture();      
              Capturer.EventHandler = this;
              Verificator = new DPFP.Verification.Verification();     // Create a fingerprint template verificator
          }
  
          protected void start()
          {
              Capturer.StartCapture();
          }
  
          protected virtual void Process(DPFP.Sample sample)
          {
  
                  drawPicture(convertingToBitmap(sample));
  
                  // Process the sample and create a feature set for the enrollment purpose.
                  DPFP.FeatureSet features = ExtractFeatures(sample, DPFP.Processing.DataPurpose.Verification);
  
                  // Check quality of the sample and start verification if it's good
                  // TODO: move to a separate task
                  if (features != null)
                  {
                      // Compare the feature set with our template
                      DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result();
                      Verificator.Verify(features, Template, ref result);
                      if (result.Verified)
                      {
                          MessageBox.Show("Login Success.");
                          this.Close(); // This the place where the exception is thrown
  
                      }
                      else
                          MessageBox.Show("The fingerprint was NOT VERIFIED.");
  
                  }
  
  
          }
  
          protected void stop()
          {
              Capturer.StopCapture();
          }
  
          protected DPFP.FeatureSet ExtractFeatures(DPFP.Sample Sample, DPFP.Processing.DataPurpose Purpose)
          {
              DPFP.Processing.FeatureExtraction Extractor = new DPFP.Processing.FeatureExtraction();  // Create a feature extractor
              DPFP.Capture.CaptureFeedback feedback = DPFP.Capture.CaptureFeedback.None;
              DPFP.FeatureSet features = new DPFP.FeatureSet();
              Extractor.CreateFeatureSet(Sample, Purpose, ref feedback, ref features);            // TODO: return features as a result?
              if (feedback == DPFP.Capture.CaptureFeedback.Good)
                  return features;
              else
                  return null;
          }
  
          private void drawPicture(Bitmap image)
          {
              this.Invoke(new Function(delegate()
              {
                  fingerprintImage.Image = new Bitmap(image, fingerprintImage.Size);
              }));
          }
  
          protected Bitmap convertingToBitmap(DPFP.Sample sample)
          {
              DPFP.Capture.SampleConversion convertor = new DPFP.Capture.SampleConversion();
              Bitmap img = null;
              convertor.ConvertToPicture(sample, ref img);
              return img;
          }
  
          #region EventHandler Members:
  
          public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
          {
              //MakeReport("The fingerprint sample was captured.");
              Process(Sample);
              closeTimer.Start();
          }
  
          public void OnFingerGone(object Capture, string ReaderSerialNumber)
          {
              // MakeReport("The finger was removed from the fingerprint reader.");
          }
  
          public void OnFingerTouch(object Capture, string ReaderSerialNumber)
          {
              // MakeReport("The fingerprint reader was touched.");
          }
  
          public void OnReaderConnect(object Capture, string ReaderSerialNumber)
          {
              //MakeReport("The fingerprint reader was connected.");
          }
  
          public void OnReaderDisconnect(object Capture, string ReaderSerialNumber)
          {
              MessageBox.Show("The fingerprint reader was disconnected.");
          }
  
          public void OnSampleQuality(object Capture, string ReaderSerialNumber, DPFP.Capture.CaptureFeedback CaptureFeedback)
          {
              //if (CaptureFeedback == DPFP.Capture.CaptureFeedback.Good)
              //    MakeReport("The quality of the fingerprint sample is good.");
              //else
              //    MakeReport("The quality of the fingerprint sample is poor.");
          }
          #endregion
  </code></pre>