By clicking on the pictureBox, I start a stream that moves the image to the coordinates of the mouse click. But, if you click on the picturebox while the image is still moving (that is, the running stream is running), the error "At the moment the object is being used by another process." . How can I fix this?
Call flow when clicking on the picturebox
Thread Thread1 = new Thread(new ThreadStart(Moving)); if (Thread1.IsAlive == true) { Thread1.Abort(); Thread1.Join(); } Thread1.Start(); The string in the stream on which I get an error
Gr.FillRectangle(Fon, 0, 0, pictureBox1.Width, pictureBox1.Height); // вот на этой Gr.FillEllipse(Fig, Width + (int)x - 9, Height + (int)y - 30, 20, 20); Gr.DrawEllipse(Pen, Width + (int)x - 9, Height + (int)y - 30, 20, 20); Gr.DrawLine(Pen, Width + x, Height + y - 20, Width + x + 20, Height + y - 15); Gr.DrawLine(Pen, Width + x, Height + y - 20, Width + x, Height + y - 15);