1

I'm trying to draw multiple ellipses on an Image from the PictureBox with a thread, but when I interact with the form (like move it), then GDI throws an InvalidOperationException (object currently in use) as I clone the current Image in the thread.

What I'm trying to achieve is to be able to animate a few shapes on the canvas, and allow the user to have a smooth experience while interacting with the form (as well as zooming in on the image etc).

What's the best way to accomplish this?

2 Answers 2

1

Keep a separate image that your background thread interacts with, and then clone it to your UI thread when there's something new to show. The cloning should be done via a BeginInvoke

0
1

You probably need to call BeginInvoke to get on the GUI thread before interacting with the PictureBox.

Like so...

form.BeginInvoke(ManipulatePictureBox);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.