LogicalMethodInfo::BeginInvoke Method
Begins an asynchronous invocation of the method represented by this LogicalMethodInfo.
Assembly: System.Web.Services (in System.Web.Services.dll)
[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")] public: IAsyncResult^ BeginInvoke( Object^ target, array<Object^>^ values, AsyncCallback^ callback, Object^ asyncState )
Parameters
- target
- Type: System::Object
The instance of the Object on which to invoke the method on.
- values
- Type: array<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 nullptr.
- callback
- Type: System::AsyncCallback
The delegate to call when the asynchronous invoke is complete. If callback is nullptr, 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 nullptr. |
| 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: [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()
{
// 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 = __typeof(MyMath::MyMath);
// Get the method info.
MethodInfo* myBeginMethod = myType->GetMethod(S"BeginAdd");
MethodInfo* myEndMethod = myType->GetMethod(S"EndAdd");
// Create an instance of the LogicalMethodInfo class.
MethodInfo* temp0 [] = {myBeginMethod,myEndMethod};
LogicalMethodInfo* myLogicalMethodInfo =
(LogicalMethodInfo::Create(temp0,
LogicalMethodTypes::Async))[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(0, MyEndIntimationMethod);
// Begin to invoke the Add method.
Object* temp1 [] = {__box(10),__box(10)};
IAsyncResult* myAsyncResult = myLogicalMethodInfo->BeginInvoke(
myMathService,temp1,myAsyncCallback,0);
// Wait until invoke is complete.
myAsyncResult->AsyncWaitHandle->WaitOne();
// Get the result.
Object* myReturnValue[];
myReturnValue = myLogicalMethodInfo->EndInvoke(myMathService,myAsyncResult);
Console::WriteLine(S"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(S"Asynchronous call on Add method finished.");
}
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.