-1

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..

  1. Locking events
  2. 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.
  3. Clone bitmap using
  • Exactly I using events in B to get image pixel source. so If i call func just in M, there is no exception. but if i checking pbxB in M & get pixel in B it cause. (Get pixel value func in mouse moving event) – Clo.Aphn Apr 09 '20 at 10:03

1 Answers1

0

Well, it solved by one passing (Set and Get) that method in Threads by using return Images in M's local variable to do checking images and drawing no each steps.. I don't know what i saying but i hope someone get helps like this problem.