Answer the question
In order to leave comments, you need to log in
How to avoid InvalidOperationException in C#?
Good afternoon! Faced such a problem. In the main thread, I open a child thread in which I work with the form object (progressBar). An exception is thrown:
Additional information: Illegal multi-thread operation: An attempt was made to access control 'pB1' from a thread other than the thread it was created on. How can this be avoided? Transferring flow work from a form is not an option. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
Work with form elements is possible only from the thread in which they are created.
If you want to update the progressBar, pass the value from your helper thread to the main thread and it will update the progressBar already
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question