次の方法で共有


RemotingServices.IsOneWay メソッド

特定のメッセージ内で指定したメソッドを呼び出したクライアントが、実行を継続する前に、このメソッドの処理をサーバーが完了するまで待機するかどうかを示す Boolean 値を返します。

Public Shared Function IsOneWay( _
   ByVal method As MethodBase _) As Boolean
[C#]
public static bool IsOneWay(MethodBasemethod);
[C++]
public: static bool IsOneWay(MethodBase* method);
[JScript]
public static function IsOneWay(
   method : MethodBase) : Boolean;

パラメータ

  • method
    該当するメソッド。

戻り値

メソッドが一方向の場合は true 。それ以外の場合は false

例外

例外の種類 条件
SecurityException 直前の呼び出し元に、インフラストラクチャ アクセス許可がありません。

解説

一方向のメソッドが呼び出された場合、クライアントはサーバーがメッセージの処理を完了するまで待機しません。クライアント メソッドは、サーバーがメッセージを正常に処理するかどうかを確認せずにアプリケーションに戻ります。メソッドは OneWayAttribute を使用して、一方向としてマークされます。

一方向のメソッドは、戻り値も out パラメータも持つことはできません。

使用例

 
Public Class HelloServer
    Inherits MarshalByRefObject

    Shared Sub New()
        Console.WriteLine("HelloServer activated.")
    End Sub

    <OneWay()> Public Sub SayHelloToServer(ByVal name As String)
        Console.WriteLine("Client invoked SayHelloToServer(""{0}"").", name)
    End Sub

    ' Note the lack of the OneWayAttribute adornment on this method.
    Public Function SayHelloToServerAndWait(ByVal name As String) As String
        Console.WriteLine("Client invoked SayHelloToServerAndWait(""{0}"").", name)

        Console.WriteLine( _
            "Client waiting for return? {0}", _
            IIf(RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()), "No", "Yes") _
        )

        Return "Hi there, " + name + "."
    End Function

End Class

[C#] 
public class HelloServer : MarshalByRefObject {

   public HelloServer() {
      Console.WriteLine("HelloServer activated.");
   }

   [OneWay()]
   public void SayHelloToServer(string name) {
      Console.WriteLine("Client invoked SayHelloToServer(\"{0}\").", name);
   }   

   // Note the lack of the OneWayAttribute adornment on this method.
   public string SayHelloToServerAndWait(string name) {
      Console.WriteLine("Client invoked SayHelloToServerAndWait(\"{0}\").", name);

      Console.WriteLine(
         "Client waiting for return? {0}",
         RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()) ? "No" : "Yes"
      );

      return "Hi there, " + name + ".";
   }
}

[C++] 
public __gc class HelloServer : public MarshalByRefObject 
{

public:
    HelloServer() 
    {
        Console::WriteLine(S"HelloServer activated.");
    }

    
public:
    [OneWay]
    void SayHelloToServer(String* name) 
    {
        Console::WriteLine(S"Client invoked SayHelloToServer(\" {0}\").", name);
    }

    // Note the lack of the OneWayAttribute adornment on this method.
public:
    String* SayHelloToServerAndWait(String* name) 
    {
        Console::WriteLine(S"Client invoked SayHelloToServerAndWait(\" {0}\").", name);

        Console::WriteLine(S"Client waiting for return? {0}",
            RemotingServices::IsOneWay(MethodBase::GetCurrentMethod()) ? S"No" : S"Yes");

        return String::Format(S"Hi there, {0}.", name);
    }
};

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

RemotingServices クラス | RemotingServices メンバ | System.Runtime.Remoting 名前空間