title: How to Capture Multiple Images Using Direct Show
body: <p>I am using Direct Show dll using web cam c#(Windows Application)
   <a href="https://i.stack.imgur.com/eKK5O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eKK5O.jpg" alt="enter image description here"></a></p>
  
  <p>when i click on capture button call :</p>
  
  <pre><code>capture.FrameEvent2 += new Capture.HeFrame(CaptureDone);
  
  
  
  private void CaptureDone(System.Drawing.Bitmap e)
          {
              if (Captured == true)
              {
                  capture.FrameEvent2 -= new Capture.HeFrame(CaptureDone); return;
              }
                  Bitmap bitmap = null;
                  bitmap = e;
                  DateTime localDate = DateTime.Now;
                  string a = localDate.ToString("ddMMMyyyy");
                  ImageCount = ImageCount + 1;
                  Image old = pictureBox1.Image;
                  pictureBox1.Image = bitmap;
                  StoreImage(pictureBox1.Image);
                  string ImageName = "";
                  ImageFormat imageFormat = null;
                  //Please Change these to opdno
                  string regno = txtOpdno.Text;
                  string filePath = Application.StartupPath + "\\SonoImage\\" + regno + "";
                  if (!Directory.Exists(filePath))
                  {
                      Directory.CreateDirectory(filePath);
                      ImageName = Convert.ToString(ImageCount) + "-" + Convert.ToString(a);
                      filePath = filePath + "\\" + ImageName + ".Jpeg";
                  }
                  else
                  {
                      ImageName = Convert.ToString(ImageCount) + "-" + Convert.ToString(a);
                      filePath = filePath + "\\" + ImageName + ".Jpeg";
                  }
                  bitmap.Save(filePath, ImageFormat.Jpeg);
                  Captured = true;
          }
  </code></pre>
  
  <p>Everythig is work properly but suddenly create :</p>
  
  <p>Object is Currently in use elsewhere
  can any one answer me why creating this type of error ?
  How to stop this ?</p>