0

I have this simple code:

 Parallel.Invoke( () => picturebox_1.Refresh(), () => picturebox_2.Refresh()); 

and I'm getting this:

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.

How can I resolve this issue? I just want to run the refresh in parallel, the refresh method runs the Paint Event which has code to render an image...

Thanks!

1 Answer 1

2

You must invoke using the UI thread, you cannot update the UI on a thread that you created, you must use the forms invoke method or the controls...

Sign up to request clarification or add additional context in comments.

2 Comments

As a result of this ui operations can'nt be parallized, because the UI only runs in one thread. Why do you want to parallelize the refresh ?
The reason I would like to parallelize the refresh is because I could refresh both controls at the same time instead of one after the other.. I think I can gain some performance by doing this?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.