调用 - 的P / InvokeInvoke

2023-09-06 22:43:44 作者:Swilder (薄年)

什么是的BeginInvoke / EndInvoke会和P / Invoke的?

what is the difference between BeginInvoke/EndInvoke and P/invoke?

推荐答案

他们只有在共同的动词援引。一般地,调用==电话。在PInvoke的的P意思是平台的PInvoke的编组是code一大块,它知道如何正确地调用原生CLR内(特定平台)code。

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的是启动一个异步方法调用大量重载方法名。编译器会自动生成每一个委托类型。随着调用和EndInvoke。他们是自动生成的,以便它们的参数匹配的委托声明。一个BeginInvoke方法也被WinForms和WPF,分别控制和调度类。完全不同的动物从委托的BeginInvoke的()方法,虽然它开始异步的东西。

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.