Getting the following error when the path is accessed concurrently.

  • Thread starter Thread starter Rehan Mubarak
  • Start date Start date
R

Rehan Mubarak

Guest
Hi ,

I have application where I am capturing a image from the camera and attaching it to a picturebox control winforms in the below code snippet

pictureBox.Image = cameraControl.GetCurrentFrame();


and then saving the image in the below code

pictureBox.Image.Save(ImgPath + @"MyImage.Png", ImageFormat.Png);

And my next operation is accessing the ImgPath and sending it to a API but when it

Thread obj = new Thread(ReadMyImage);
obj.Start();


ReadMyImage is the method which access the path and sends it to API.

Now I am getting following error when the picturebox.Save operation is done

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at Serial_Communication.MainInterface.<StartProcess>d__52.MoveNext() in C:\Users\LENOVO\Downloads\MyApplication.cs:line 858
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)


Could you please let me know how can i solve this ?

Continue reading...
 
Back
Top