Is there a Form.Invoke () method?

I am new to multithreading (and also in C #), so I hope this is not obvious:

In my form (WinForms application, .NET 2.0), I signed up for an event raised by another object, and when processing this event, I want to change several controls in my form. Since this event occurs in a different thread than in the main (UI) thread, I want to march the call to the form stream.

I understand that I could use the Control.Invoke () method for any control that I want to change, but since there are several of them, I do not want to do this.

When I searched the Internet, I found that the Form class itself provides the Invoke () method. See For example: http://marioschneider.blogspot.com/2008/04/invoke-methode-fr-multithread.html (Sorry, as I am a new user, I cannot post more than one link. I will add more links as comments if possible.)

With this, I could just wrap the event handler and then use it as if it were called in a UI thread. However, this does not look like a definition in my environment, and the MSDN System.Windows.Forms.Form documentation also does not show any signs of this.

Does this method exist in the .NET Framework? I find it hard to believe that Form will not provide such a method because it uses the same message queue as the controls. (Or am I missing something?)

+3
source share
1 answer

There's an Invoke method on Formsince it comes from Control.

+5
source

Source: https://habr.com/ru/post/1744491/


All Articles