February 2003
Intermediate to advanced
752 pages
16h 35m
English
Callbacks are one of the preferred ways to handle asynchronous calls because they simplify your code and eliminate the overhead of having to continuously poll a request that is in progress to see whether it has completed. The second-to-last parameter of the BeginInvoke method (or BeginMethodName in an XML Web service proxy class) accepts a reference to the method that you want triggered when the method call is complete.
To use a callback successfully, your callback method must have the same signature as the System.AsyncCallback delegate. That means it needs to accept a single IAsyncResult parameter. Here’s an example:
Public Sub AsyncCallback(ByVal ar As IAsyncResult) ‘ (This code will be triggered when the method call is complete.) ...
Read now
Unlock full access