Pergunta

This question may sound trivial, but let me ask it nevertheless.

I found on the Internet the following example of calling an anonymous method using Invoke in VB.NET:

Invoke(New MethodInvoker(Sub() SomeMethod(param1)))

But why not call it this way, which looks cleaner? Is there any difference?

Invoke(Sub() SomeMethod(param1))
Foi útil?

Solução

Just to conclude and close the topic. Based on the comments, both the examples of Invoke calls are correct, but the one using MethodInvoker instantiation is faster, because no extra typecasting has to be performed at runtime, as MrPaulch stated.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top