LogicalMethodInfo.BeginInvoke Method (Object, Object(), AsyncCallback, Object)
Begins an asynchronous invocation of the method represented by this LogicalMethodInfo.
Assembly: System.Web.Services (in System.Web.Services.dll)
<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")> Public Function BeginInvoke ( target As Object, values As Object(), callback As AsyncCallback, asyncState As Object ) As IAsyncResult
Parameters
- target
-
Type:
System.Object
The instance of the Object on which to invoke the method on.
- values
-
Type:
System.Object()
An argument list for the invoked method. This is an array of objects with the same number, order, and type as the parameters of the method. If the method does not require any parameters, values should be null.
- callback
-
Type:
System.AsyncCallback
The delegate to call when the asynchronous invoke is complete. If callback is null, the delegate is not called.
- asyncState
-
Type:
System.Object
State information that is passed on to the delegate.
Return Value
Type: System.IAsyncResultAn IAsyncResult which is passed to EndInvoke to obtain the return values from the remote method call.
| Exception | Condition |
|---|---|
| TargetException | The target parameteris null. |
| ArgumentException | The number, type, and order of parameters in values do not match the signature of the invoked method. |
| MemberAccessException | The caller does not have permission to invoke the method. |
Public Shared Sub Main() ' Get the type information. ' Note: The MyMath class is a proxy class generated by the Wsdl.exe ' utility for the Math Web Service. This class can also be found in ' the SoapHttpClientProtocol class example. Dim myType As Type = GetType(MyMath.MyMath) ' Get the method info. Dim myBeginMethod As MethodInfo = myType.GetMethod("BeginAdd") Dim myEndMethod As MethodInfo = myType.GetMethod("EndAdd") ' Create an instance of the LogicalMethodInfo class. Dim myLogicalMethodInfo As LogicalMethodInfo = _ LogicalMethodInfo.Create(New MethodInfo() {myBeginMethod, myEndMethod}, _ LogicalMethodTypes.Async)(0) ' Get an instance of the proxy class. Dim myMathService As New MyMath.MyMath() ' Call the MyEndIntimationMethod method to intimate the end of ' the asynchronous call. Dim myAsyncCallback As New AsyncCallback(AddressOf MyEndIntimationMethod) ' Beging to invoke the Add method. Dim myAsyncResult As IAsyncResult = _ myLogicalMethodInfo.BeginInvoke( _ myMathService, New Object() {10, 10}, myAsyncCallback, Nothing) ' Wait until invoke is complete. myAsyncResult.AsyncWaitHandle.WaitOne() ' Get the result. Dim myReturnValue() As Object myReturnValue = myLogicalMethodInfo.EndInvoke(myMathService, myAsyncResult) Console.WriteLine(("Sum of 10 and 10 is " & myReturnValue(0))) End Sub ' This method will be called at the end of asynchronous call. Shared Sub MyEndIntimationMethod(ByVal Result As IAsyncResult) Console.WriteLine("Asynchronous call on method 'Add' finished.") End Sub
Available since 1.1