英語で読む

次の方法で共有


DuplexClientBase<TChannel> クラス

定義

双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。

C#
public abstract class DuplexClientBase<TChannel> : System.ServiceModel.ClientBase<TChannel> where TChannel : class

型パラメーター

TChannel

作成するチャネルの種類。

継承
DuplexClientBase<TChannel>

次の例は、双方向 WCF クライアント型のクライアント (SampleDuplexHelloClient) を使用して、コールバック をリッスンするコールバック オブジェクトを持つ新しい System.ServiceModel.InstanceContext オブジェクトを渡す方法を示しています。

C#
using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Threading;

namespace Microsoft.WCF.Documentation
{
  [CallbackBehaviorAttribute(
   IncludeExceptionDetailInFaults= true,
    UseSynchronizationContext=true,
    ValidateMustUnderstand=true
  )]
  public class Client : SampleDuplexHelloCallback
  {
    AutoResetEvent waitHandle;

    public Client()
    {
      waitHandle = new AutoResetEvent(false);
    }

    public void Run()
    {
      // Picks up configuration from the configuration file.
      SampleDuplexHelloClient wcfClient
        = new SampleDuplexHelloClient(new InstanceContext(this), "WSDualHttpBinding_SampleDuplexHello");
      try
      {
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Enter a greeting to send and press ENTER: ");
        Console.Write(">>> ");
        Console.ForegroundColor = ConsoleColor.Green;
        string greeting = Console.ReadLine();
        Console.ForegroundColor = ConsoleColor.White;
        Console.WriteLine("Called service with: \r\n\t" + greeting);
        wcfClient.Hello(greeting);
        Console.WriteLine("Execution passes service call and moves to the WaitHandle.");
        this.waitHandle.WaitOne();
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.WriteLine("Set was called.");
        Console.Write("Press ");
        Console.ForegroundColor = ConsoleColor.Red;
        Console.Write("ENTER");
        Console.ForegroundColor = ConsoleColor.Blue;
        Console.Write(" to exit...");
        Console.ReadLine();
      }
      catch (TimeoutException timeProblem)
      {
        Console.WriteLine("The service operation timed out. " + timeProblem.Message);
        Console.ReadLine();
      }
      catch (CommunicationException commProblem)
      {
        Console.WriteLine("There was a communication problem. " + commProblem.Message);
        Console.ReadLine();
      }
    }
    public static void Main()
    {
      Client client = new Client();
      client.Run();
    }

    public void Reply(string response)
    {
      Console.WriteLine("Received output.");
      Console.WriteLine("\r\n\t" + response);
      this.waitHandle.Set();
    }
  }
}

注釈

DuplexClientBase<TChannel> クラスを使用して、コールバック オブジェクトを指定するサービスへのチャネルを作成します。 DuplexClientBase<TChannel> オブジェクトは、WCF オブジェクトの接続を提供する System.ServiceModel.DuplexChannelFactory<TChannel> オブジェクトをラップします。 どちらの種類を使用しても、双方向サービスに接続できます。 双方向サービスの詳細については、「双方向サービスの」を参照してください。

このクラスから派生するマネージド C++ ユーザーの特別な注意:

  • デストラクターではなく、クリーンアップ コードを (On)(Begin)Close (または OnAbort) に配置します。

  • デストラクターを回避する: コンパイラによって IDisposable が自動生成されます

  • 参照以外のメンバーを避ける: コンパイラが IDisposable を自動生成する可能性があります

  • ファイナライザーを使用しないでください。ただし、ビルド警告を含める場合は、自動生成された IDisposable 動作をエミュレートするために、ビルド警告を抑制し、SuppressFinalize(Object) とファイナライザー自体を (On)(Begin)Close (または OnAbort) から呼び出す必要があります。

コンストラクター

DuplexClientBase<TChannel>(InstanceContext)

指定したコールバック オブジェクトを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(InstanceContext, Binding, EndpointAddress)

指定したコールバック オブジェクト、バインディング、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(InstanceContext, ServiceEndpoint)

指定したコールバック オブジェクトとサービス エンドポイントを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(InstanceContext, String)

指定したコールバック オブジェクトと構成名を使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(InstanceContext, String, EndpointAddress)

指定したコールバック オブジェクト、構成名、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(InstanceContext, String, String)

指定したコールバック オブジェクト、構成名、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object)

指定したコールバック オブジェクトを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object, Binding, EndpointAddress)

指定したコールバック オブジェクト、バインディング、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object, ServiceEndpoint)

指定したコールバック オブジェクトとサービス エンドポイントを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object, String)

指定したコールバック オブジェクトと構成名を使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object, String, EndpointAddress)

指定したコールバック オブジェクト、構成名、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

DuplexClientBase<TChannel>(Object, String, String)

指定したコールバック オブジェクト、エンドポイント構成名、およびサービス エンドポイント アドレスを使用して、DuplexClientBase<TChannel> クラスの新しいインスタンスを初期化します。

プロパティ

Channel

さまざまな構成済みのサービス エンドポイントにメッセージを送信するために使用される内部チャネルを取得します。

(継承元 ClientBase<TChannel>)
ChannelFactory

基になる ChannelFactory<TChannel> オブジェクトを取得します。

(継承元 ClientBase<TChannel>)
ClientCredentials

操作の呼び出しに使用されるクライアント資格情報を取得します。

(継承元 ClientBase<TChannel>)
Endpoint

WCF クライアントが接続できるサービスのターゲット エンドポイントを取得します。

(継承元 ClientBase<TChannel>)
InnerChannel

基になる IClientChannel 実装を取得します。

(継承元 ClientBase<TChannel>)
InnerDuplexChannel

双方向チャネルの基になる IClientChannel 実装を取得します。

State

ClientBase<TChannel> オブジェクトの現在の状態を取得します。

(継承元 ClientBase<TChannel>)

メソッド

Abort()

ClientBase<TChannel> オブジェクトを現在の状態から閉じた状態に直ちに遷移させます。

(継承元 ClientBase<TChannel>)
Close()

ClientBase<TChannel> オブジェクトを現在の状態から閉じた状態に遷移させます。

(継承元 ClientBase<TChannel>)
CloseAsync()

双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。

(継承元 ClientBase<TChannel>)
CreateChannel()

コンストラクターに渡されたコールバック オブジェクトに関連付けられているサービスへのチャネルを返します。

CreateChannel()

サービスに新しいチャネルを返します。

(継承元 ClientBase<TChannel>)
DisplayInitializationUI()

チャネルを使用する前に初期化する必要がある場合は、ユーザー インターフェイスを表示するように内部チャネルに指示します。

(継承元 ClientBase<TChannel>)
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetDefaultValueForInitialization<T>()

C# の既定のキーワードの動作をレプリケートします。

(継承元 ClientBase<TChannel>)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
InvokeAsync(ClientBase<TChannel>.BeginOperationDelegate, Object[], ClientBase<TChannel>.EndOperationDelegate, SendOrPostCallback, Object)

イベント ベースの非同期パターンを実装するためのサポートを提供します。 このパターンの詳細については、「イベント ベースの非同期パターンの概要」を参照してください。

(継承元 ClientBase<TChannel>)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
Open()

ClientBase<TChannel> オブジェクトが作成された状態から開かれた状態に遷移します。

(継承元 ClientBase<TChannel>)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

IAsyncDisposable.DisposeAsync()

双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。

(継承元 ClientBase<TChannel>)
ICommunicationObject.BeginClose(AsyncCallback, Object)

ClientBase<TChannel>を閉じる非同期操作を開始します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.BeginClose(TimeSpan, AsyncCallback, Object)

指定したタイムアウトで ClientBase<TChannel> を閉じる非同期操作を開始します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.BeginOpen(AsyncCallback, Object)

ClientBase<TChannel> オブジェクトを開く非同期操作を開始します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.BeginOpen(TimeSpan, AsyncCallback, Object)

指定した時間内に ClientBase<TChannel> オブジェクトを開く非同期操作を開始します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Close()

通信オブジェクトを現在の状態から閉じた状態に遷移させます。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Close(TimeSpan)

ClientBase<TChannel> オブジェクトを現在の状態から閉じた状態に遷移させます。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Closed

ClientBase<TChannel> オブジェクトが現在の状態から閉じた状態に遷移したときに呼び出されるイベント ハンドラー。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Closing

ClientBase<TChannel> オブジェクトが現在の状態から閉じた状態に遷移したときに呼び出されるイベント ハンドラー。

(継承元 ClientBase<TChannel>)
ICommunicationObject.EndClose(IAsyncResult)

ClientBase<TChannel> オブジェクトを閉じる非同期操作を完了します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.EndOpen(IAsyncResult)

ClientBase<TChannel> オブジェクトを開く非同期操作を完了します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Faulted

ClientBase<TChannel> オブジェクトに対する操作の実行中にエラーが発生したときに呼び出されるイベント ハンドラー。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Open()

通信オブジェクトが作成された状態から開かれた状態に遷移します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Open(TimeSpan)

指定した時間内に、ClientBase<TChannel> オブジェクトが作成された状態から開かれた状態に遷移します。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Opened

ClientBase<TChannel> オブジェクトが作成された状態から開かれた状態に遷移したときに呼び出されるイベント ハンドラー。

(継承元 ClientBase<TChannel>)
ICommunicationObject.Opening

ClientBase<TChannel> オブジェクトが作成された状態から開かれた状態に遷移したときに呼び出されるイベント ハンドラー。

(継承元 ClientBase<TChannel>)
IDisposable.Dispose()

Dispose() メソッドの明示的な実装。

(継承元 ClientBase<TChannel>)

拡張メソッド

ConfigureAwait(IAsyncDisposable, Boolean)

非同期破棄から返されるタスクの待機を実行する方法を構成します。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, 8
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
UWP 10.0