LogicalMethodInfo.BeginInvoke Method
Assembly: System.Web.Services (in system.web.services.dll)
public: IAsyncResult^ BeginInvoke ( Object^ target, array<Object^>^ values, AsyncCallback^ callback, Object^ asyncState )
public IAsyncResult BeginInvoke ( Object target, Object[] values, AsyncCallback callback, Object asyncState )
public function BeginInvoke ( target : Object, values : Object[], callback : AsyncCallback, asyncState : Object ) : IAsyncResult
Not applicable.
Parameters
- target
The instance of the Object on which to invoke the method on.
- values
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 a null reference (Nothing in Visual Basic).
- callback
The delegate to call when the asynchronous invoke is complete. If callback is a null reference (Nothing in Visual Basic), the delegate is not called.
- asyncState
State information that is passed on to the delegate.
Return Value
An IAsyncResult which is passed to EndInvoke to obtain the return values from the remote method call.public: [PermissionSet(SecurityAction::Demand, Name="FullTrust")] static void 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. Type^ myType = MyMath::MyMath::typeid; // Get the method info. MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" ); MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" ); // Create an instance of the LogicalMethodInfo class. array<MethodInfo^>^ temp0 = { myBeginMethod, myEndMethod }; LogicalMethodInfo^ myLogicalMethodInfo = ( LogicalMethodInfo::Create( temp0, LogicalMethodTypes::Async ) )[ 0 ]; // Get an instance of the proxy class. MyMath::MyMath^ myMathService = gcnew MyMath::MyMath; // Call the MyEndIntimationMethod method to intimate the end of // the asynchronous call. AsyncCallback^ myAsyncCallback = gcnew AsyncCallback( MyEndIntimationMethod ); // Begin to invoke the Add method. array<Object^>^ temp1 = { 10, 10 }; IAsyncResult^ myAsyncResult = myLogicalMethodInfo->BeginInvoke( myMathService, temp1, myAsyncCallback, nullptr ); // Wait until invoke is complete. myAsyncResult->AsyncWaitHandle->WaitOne(); // Get the result. array<Object^>^ myReturnValue; myReturnValue = myLogicalMethodInfo->EndInvoke( myMathService, myAsyncResult ); Console::WriteLine( "Sum of 10 and 10 is {0}", myReturnValue[ 0 ] ); } // This method will be called at the end of the asynchronous call. static void MyEndIntimationMethod( IAsyncResult^ /*Result*/ ) { Console::WriteLine( "Asynchronous call on Add method finished." ); }
public static void main(String[] args)
{
// 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.
Type myType = MyMath.MyMath.class.ToType();
// Get the method info.
MethodInfo myBeginMethod = myType.GetMethod("BeginAdd");
MethodInfo myEndMethod = myType.GetMethod("EndAdd");
// Create an instance of the LogicalMethodInfo class.
LogicalMethodInfo myLogicalMethodInfo = (LogicalMethodInfo)(
LogicalMethodInfo.Create(new MethodInfo[] { myBeginMethod,
myEndMethod }, LogicalMethodTypes.Async).get_Item(0));
// Get an instance of the proxy class.
MyMath.MyMath myMathService = new MyMath.MyMath();
// Call the MyEndIntimationMethod method to intimate the end of
// the asynchronous call.
AsyncCallback myAsyncCallback = new AsyncCallback(MyEndIntimationMethod);
// Begin to invoke the Add method.
IAsyncResult myAsyncResult = myLogicalMethodInfo.BeginInvoke(
myMathService, new Object[] { (Int32)10, (Int32)10 },
myAsyncCallback, null);
// Wait until invoke is complete.
myAsyncResult.get_AsyncWaitHandle().WaitOne();
// Get the result.
Object myReturnValue[];
myReturnValue = myLogicalMethodInfo.EndInvoke(myMathService,
myAsyncResult);
Console.WriteLine("Sum of 10 and 10 is " + myReturnValue.get_Item(0));
} //main
// This method will be called at the end of the asynchronous call.
static void MyEndIntimationMethod(IAsyncResult Result)
{
Console.WriteLine("Asynchronous call on Add method finished.");
} //MyEndIntimationMethod
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.