开发者

invoke - p/invoke

开发者 https://www.devze.com 2023-02-09 05:36 出处:网络
what is the difference between BeginInvoke/EndInvoke and P/invoke?开发者_StackOverflow中文版They only have the verb \"invoke\" in common.Generically, invoke == call.The p in pinvoke means \"platform\"

what is the difference between BeginInvoke/EndInvoke and P/invoke?开发者_StackOverflow中文版


They only have the verb "invoke" in common. Generically, invoke == call. The p in pinvoke means "platform", the pinvoke marshaller is a chunk of code inside the CLR that knows how to properly call native (platform specific) code.

BeginInvoke is a heavily overloaded method name that starts an asynchronous method call. The compiler automatically generates one for every delegate type. Along with Invoke and EndInvoke. They are auto-generated so their arguments match the delegate declaration. A BeginInvoke method is also used by Winforms and WPF, respectively the Control and Dispatcher classes. Quite a different animal from a delegate's BeginInvoke() method, although it does start something asynchronously.


BeginInvoke/EndInvoke are used in asynchronous programming to invoke a delegate on another thread. P/invoke is used to call unmanaged code.

0

精彩评论

暂无评论...
验证码 换一张
取 消