LogicalMethodInfo.EndInvoke Method (Object, IAsyncResult)

 

Ends an asynchronous invocation of the method represented by the current LogicalMethodInfo.

Namespace:   System.Web.Services.Protocols
Assembly:  System.Web.Services (in System.Web.Services.dll)

<PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")>
Public Function EndInvoke (
	target As Object,
	asyncResult As IAsyncResult
) As Object()

Parameters

target
Type: System.Object

The instance of the Object on which to invoke the method.

asyncResult
Type: System.IAsyncResult

The IAsyncResult returned from BeginInvoke.

Return Value

Type: System.Object()

An array of objects containing the return value and any by-reference or out parameters of the derived class method.

Exception Condition
TargetException

The target parameter is null.

MemberAccessException

The caller does not have permission to invoke the method.

TargetInvocationException

The invoked method throws an exception.

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

.NET Framework
Available since 1.1
Return to top
Show: