I am using Direct Show dll using web cam c#(Windows Application)
when i click on capture button call :
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;
}
Everythig is work properly but suddenly create :
Object is Currently in use elsewhere can any one answer me why creating this type of error ? How to stop this ?