I found this code:
this.Invoke(new EventHandler(EventGetSum));
Is this not the same as writing:
EventGetSum();
What’s the use of this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you write
EventGetSum()that immediately calls the EventGetSum method.If you write
new EventHandler(EventGetSum)that creates a delegate which will (in turn) call EventGetSum when it’s invoked.The call to
Control.Invokeinvokes the given delegate from the UI thread responsible for the control. This is necessary because you mustn’t access UI elements from arbitrary threads.