I have seen previous topics same errors, but there is no idea how can fix it.
To explain the current my situation, I am coding a program has Main form(M) and it make instance form(B) to show Form in Form Main UI by docking. B has picturebox that showing Images.
my problem is Getting B's PictureBox. Image by delegate events to check the image and draw graphics in M & B both. M has threads to get B's image and draw B's picturebox..
in Form B class,
public void PbxPaintevent(ref Bitmap img, bool _Flag)
{
lock (locking)
{
if(_Flag)
{
img = pbxB.Image.Clone();
}
else pbxB.Image = img;
}
}
this events calls in M's thread, and B itself.
i do my best to solve it all day but no idea..
- Locking events
- gloabal variable to locking where func pbx's image drawing -> my mistake that i can't do that like message queue.. it occur like Simultaneous things.
- Clone bitmap using