문제

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))
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top