object is currently use elsewhere while rotate picturebox

127 Views Asked by At

I have three images each one in a picturebox and when threads starts they begin to rotate

threads[0] = new Thread(new ThreadStart(Display1));
        place(ref threads[0], comboBox1.SelectedIndex);
        threads[0].Start();

then in display1 function i use below code to rotate

   protected void Display1()
    {
        for (long i = 0L; i < 200000; i++)
        {


            {
                Image img = pictureBox1.Image;
                img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                pictureBox1.Refresh();
            }
        }

    }

but it just gets unhandled exception "Object is currently use elsewhere" i try to use lock and picturebox1.invalidate but i has no use.

0

There are 0 best solutions below