LogicalMethodInfo.AsyncCallbackParameter プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
非同期呼び出しの Begin メソッドの AsyncCallback
パラメーターのパラメーター情報を取得します。
public:
property System::Reflection::ParameterInfo ^ AsyncCallbackParameter { System::Reflection::ParameterInfo ^ get(); };
public System.Reflection.ParameterInfo AsyncCallbackParameter { get; }
member this.AsyncCallbackParameter : System.Reflection.ParameterInfo
Public ReadOnly Property AsyncCallbackParameter As ParameterInfo
プロパティ値
Begin
非同期メソッド呼び出しの AsyncCallback
パラメーターを表す ParameterInfo。
例
#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 System;
using System.Reflection;
using System.Web.Services.Protocols;
public class MyService : SoapHttpClientProtocol
{
public IAsyncResult BeginAdd(int xValue, int yValue,
AsyncCallback callback,
object asyncState)
{
return this.BeginInvoke("Add", new object[] {xValue,yValue}, callback, asyncState);
}
public int EndAdd(System.IAsyncResult asyncResult)
{
object[] results = this.EndInvoke(asyncResult);
return ((int)(results[0]));
}
}
public class LogicalMethodInfo_Create
{
public static void Main()
{
Type myType = typeof(MyService);
MethodInfo myBeginMethod = myType.GetMethod("BeginAdd");
MethodInfo myEndMethod = myType.GetMethod("EndAdd");
LogicalMethodInfo myLogicalMethodInfo =
(LogicalMethodInfo.Create(new MethodInfo[] { myBeginMethod,
myEndMethod },
LogicalMethodTypes.Async))[0];
Console.WriteLine("\nThe asynchronous callback parameter of method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.AsyncCallbackParameter.Name +
" : " + myLogicalMethodInfo.AsyncCallbackParameter.ParameterType);
Console.WriteLine("\nThe asynchronous state parameter of method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.AsyncStateParameter.Name +
" : " + myLogicalMethodInfo.AsyncStateParameter.ParameterType);
Console.WriteLine("\nThe asynchronous result parameter of method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.AsyncResultParameter.Name +
" : " + myLogicalMethodInfo.AsyncResultParameter.ParameterType);
Console.WriteLine("\nThe begin method of the asynchronous method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.BeginMethodInfo);
Console.WriteLine("\nThe end method of the asynchronous method {0} is :\n",
myLogicalMethodInfo.Name);
Console.WriteLine("\t" + myLogicalMethodInfo.EndMethodInfo);
if(myLogicalMethodInfo.IsAsync)
Console.WriteLine("\n{0} is asynchronous", myLogicalMethodInfo.Name);
else
Console.WriteLine("\n{0} is synchronous", myLogicalMethodInfo.Name);
}
}
Imports System.Reflection
Imports System.Web.Services.Protocols
Public Class MyService
Inherits SoapHttpClientProtocol
Public Function BeginAdd _
(xValue As Integer, yValue As Integer, callback As AsyncCallback, asyncState As Object) _
As IAsyncResult
Return Me.BeginInvoke("Add", New Object() {xValue, yValue}, callback, asyncState)
End Function 'BeginAdd
Public Function EndAdd(asyncResult As System.IAsyncResult) As Integer
Dim results As Object() = Me.EndInvoke(asyncResult)
Return CInt(results(0))
End Function 'EndAdd
End Class
Public Class LogicalMethodInfo_Create
Public Shared Sub Main()
Dim myType As Type = GetType(MyService)
Dim myBeginMethod As MethodInfo = myType.GetMethod("BeginAdd")
Dim myEndMethod As MethodInfo = myType.GetMethod("EndAdd")
Dim myLogicalMethodInfo As LogicalMethodInfo = _
LogicalMethodInfo.Create(New MethodInfo() _
{myBeginMethod, myEndMethod}, LogicalMethodTypes.Async)(0)
Console.WriteLine _
(ControlChars.Newline + "The asynchronous callback parameter of method {0} is :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
Console.WriteLine _
(ControlChars.Tab + myLogicalMethodInfo.AsyncCallbackParameter.Name + " : " + _
myLogicalMethodInfo.AsyncCallbackParameter.ParameterType.ToString())
Console.WriteLine _
(ControlChars.Newline + "The asynchronous state parameter of method {0} is :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
Console.WriteLine _
(ControlChars.Tab + myLogicalMethodInfo.AsyncStateParameter.Name + " : " + _
myLogicalMethodInfo.AsyncStateParameter.ParameterType.ToString())
Console.WriteLine _
(ControlChars.Newline + "The asynchronous result parameter of method {0} is :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
Console.WriteLine _
(ControlChars.Tab + myLogicalMethodInfo.AsyncResultParameter.Name + " : " + _
myLogicalMethodInfo.AsyncResultParameter.ParameterType.ToString())
Console.WriteLine _
(ControlChars.Newline + "The begin method of the asynchronous method {0} is :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.BeginMethodInfo.ToString())
Console.WriteLine _
(ControlChars.Newline + "The end method of the asynchronous method {0} is :" + _
ControlChars.Newline, myLogicalMethodInfo.Name)
Console.WriteLine(ControlChars.Tab + myLogicalMethodInfo.EndMethodInfo.ToString())
If myLogicalMethodInfo.IsAsync Then
Console.WriteLine(ControlChars.Newline + "{0} is asynchronous", myLogicalMethodInfo.Name)
Else
Console.WriteLine(ControlChars.Newline + "{0} is synchronous", myLogicalMethodInfo.Name)
End If
End Sub
End Class
注釈
共通言語ランタイムの非同期設計パターンには、メソッドを Begin
呼び出して非同期メソッド呼び出しを開始し、メソッドを呼び出して呼び出しを End
完了する必要があります。 メソッドは Begin
、メソッドの同期バージョンで定義されたパラメーターに加えて、2 つの追加パラメーターを受け取ります。1 つはデリゲートを格納し、もう 1 つはデリゲートに渡す必要がある状態情報を格納します。 このプロパティは、パラメーター名が のデリゲートのパラメーターを表します AsyncCallback
。
XML Web サービスを非同期的に呼び出す方法の詳細については、「 XML Web サービスとの非同期通信」を参照してください。
適用対象
こちらもご覧ください
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET