This documentation is archived and is not being maintained.

LogicalMethodInfo::AsyncStateParameter Property

Gets the parameter information for the AsyncState parameter of a Begin method in an asynchronous invocation.

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

public:
property ParameterInfo^ AsyncStateParameter {
	ParameterInfo^ get ();
}

Property Value

Type: System.Reflection::ParameterInfo
A ParameterInfo representing the AsyncState parameter of a Begin method in an asynchronous invocation.

The asynchronous design pattern in the common language runtime involves calling a Begin method to start the asynchronous method invocation and an End method to complete the invocation. The Begin method takes two additional parameters besides the parameters defined by the synchronous version of the method: one to store a delegate and one to store any state information that needs to be passed on to the delegate. This property represents the state information that needs to be passed into the delegate.

For more information on invoking XML Web services asynchronously, see [<topic://cpconInvokingWebServicesAsynchronously>].

#using <System.dll>
#using <System.Web.dll>
#using <System.Web.Services.dll>
#using <System.Xml.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public ref class MyService: public SoapHttpClientProtocol
{
public:
   IAsyncResult^ BeginAdd( int xValue, int yValue, AsyncCallback^ callback, Object^ asyncState )
   {
      array<Object^>^temp0 = {xValue,yValue};
      return this->BeginInvoke( "Add", temp0, callback, asyncState );
   }

   int EndAdd( System::IAsyncResult^ asyncResult )
   {
      array<Object^>^results = this->EndInvoke( asyncResult );
      return  *dynamic_cast<int^>(results[ 0 ]);
   }
};

int main()
{
   Type^ myType = MyService::typeid;
   MethodInfo^ myBeginMethod = myType->GetMethod( "BeginAdd" );
   MethodInfo^ myEndMethod = myType->GetMethod( "EndAdd" );
   array<MethodInfo^>^temp0 = {myBeginMethod,myEndMethod};
   LogicalMethodInfo^ myLogicalMethodInfo = LogicalMethodInfo::Create( temp0, LogicalMethodTypes::Async )[ 0 ];
   Console::WriteLine( "\nThe asynchronous callback parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncCallbackParameter->Name, myLogicalMethodInfo->AsyncCallbackParameter->ParameterType );
   Console::WriteLine( "\nThe asynchronous state parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncStateParameter->Name, myLogicalMethodInfo->AsyncStateParameter->ParameterType );
   Console::WriteLine( "\nThe asynchronous result parameter of method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0} : {1}", myLogicalMethodInfo->AsyncResultParameter->Name, myLogicalMethodInfo->AsyncResultParameter->ParameterType );
   Console::WriteLine( "\nThe begin method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->BeginMethodInfo );
   Console::WriteLine( "\nThe end method of the asynchronous method {0} is :\n", myLogicalMethodInfo->Name );
   Console::WriteLine( "\t {0}", myLogicalMethodInfo->EndMethodInfo );
   if ( myLogicalMethodInfo->IsAsync )
      Console::WriteLine( "\n {0} is asynchronous", myLogicalMethodInfo->Name );
   else
      Console::WriteLine( "\n {0} is synchronous", myLogicalMethodInfo->Name );
}
#using <mscorlib.dll>
#using <System.dll>
#using <System.Web.dll>
#using <System.Web.Services.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Web::Services::Protocols;

public __gc class MyService : public SoapHttpClientProtocol {
public:
   IAsyncResult* BeginAdd(int xValue, int yValue,
      AsyncCallback* callback,
      Object* asyncState) {

         Object* temp0 [] = {__box(xValue), __box(yValue)};

         return this->BeginInvoke(S"Add", temp0, callback, asyncState);
      }

public:
   int EndAdd(System::IAsyncResult* asyncResult) {
      Object* results[] = this->EndInvoke(asyncResult);
      return *dynamic_cast<int __gc *>(results[0]);
   }
};

int main() {
   Type*  myType = __typeof(MyService);
   MethodInfo*  myBeginMethod = myType->GetMethod(S"BeginAdd");
   MethodInfo*  myEndMethod = myType->GetMethod(S"EndAdd");
   MethodInfo* temp0 [] = {myBeginMethod, myEndMethod};
   LogicalMethodInfo* myLogicalMethodInfo = 
      LogicalMethodInfo::Create(temp0, LogicalMethodTypes::Async)[0];

   Console::WriteLine(S"\nThe asynchronous callback parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncCallbackParameter->Name,
      myLogicalMethodInfo->AsyncCallbackParameter->ParameterType);

   Console::WriteLine(S"\nThe asynchronous state parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncStateParameter->Name,
      myLogicalMethodInfo->AsyncStateParameter->ParameterType);

   Console::WriteLine(S"\nThe asynchronous result parameter of method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0} : {1}", myLogicalMethodInfo->AsyncResultParameter->Name,
      myLogicalMethodInfo->AsyncResultParameter->ParameterType);

   Console::WriteLine(S"\nThe begin method of the asynchronous method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->BeginMethodInfo);

   Console::WriteLine(S"\nThe end method of the asynchronous method {0} is :\n",
      myLogicalMethodInfo->Name);
   Console::WriteLine(S"\t {0}", myLogicalMethodInfo->EndMethodInfo);

   if (myLogicalMethodInfo->IsAsync)
      Console::WriteLine(S"\n {0} is asynchronous", 
      myLogicalMethodInfo->Name);
   else
      Console::WriteLine(S"\n {0} is synchronous", 
      myLogicalMethodInfo->Name);
}

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.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: