DuplexClientBase<TChannel> クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。
generic <typename TChannel>
where TChannel : classpublic ref class DuplexClientBase abstract : System::ServiceModel::ClientBase<TChannel>
public abstract class DuplexClientBase<TChannel> : System.ServiceModel.ClientBase<TChannel> where TChannel : class
type DuplexClientBase<'Channel (requires 'Channel : null)> = class
inherit ClientBase<'Channel (requires 'Channel : null)>
Public MustInherit Class DuplexClientBase(Of TChannel)
Inherits ClientBase(Of TChannel)
型パラメーター
- TChannel
作成されるチャネルの種類。
- 継承
例
次の例は、双方向 WCF クライアント型のクライアントで、 を使用してコールバック SampleDuplexHelloClient
オブジェクトと共に新しい System.ServiceModel.InstanceContext オブジェクトを渡してコールバックをリッスンする方法を示しています。
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();
}
}
}
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Threading
Namespace Microsoft.WCF.Documentation
<CallbackBehaviorAttribute(IncludeExceptionDetailInFaults:= True, UseSynchronizationContext:=True, ValidateMustUnderstand:=True)> _
Public Class Client
Implements SampleDuplexHelloCallback
Private waitHandle As AutoResetEvent
Public Sub New()
waitHandle = New AutoResetEvent(False)
End Sub
Public Sub Run()
' Picks up configuration from the configuration file.
Dim wcfClient As New SampleDuplexHelloClient(New InstanceContext(Me), "WSDualHttpBinding_SampleDuplexHello")
Try
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Enter a greeting to send and press ENTER: ")
Console.Write(">>> ")
Console.ForegroundColor = ConsoleColor.Green
Dim greeting As String = Console.ReadLine()
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Called service with: " & Constants.vbCrLf & Constants.vbTab & greeting)
wcfClient.Hello(greeting)
Console.WriteLine("Execution passes service call and moves to the WaitHandle.")
Me.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 timeProblem As TimeoutException
Console.WriteLine("The service operation timed out. " & timeProblem.Message)
Console.ReadLine()
Catch commProblem As CommunicationException
Console.WriteLine("There was a communication problem. " & commProblem.Message)
Console.ReadLine()
End Try
End Sub
Public Shared Sub Main()
Dim client As New Client()
client.Run()
End Sub
Public Sub Reply(ByVal response As String) Implements SampleDuplexHelloCallback.Reply
Console.WriteLine("Received output.")
Console.WriteLine(Constants.vbCrLf & Constants.vbTab & response)
Me.waitHandle.Set()
End Sub
End Class
End Namespace
注釈
DuplexClientBase<TChannel> クラスを使用して、コールバック オブジェクトを指定するサービスへのチャネルを作成します。 オブジェクトは DuplexClientBase<TChannel> 、WCF オブジェクトの接続を提供する オブジェクトをラップ System.ServiceModel.DuplexChannelFactory<TChannel> します。 どちらの種類でも、双方向サービスに接続できます。 双方向サービスの詳細については、「双方向サービス」を参照してください。
このクラスから派生するマネージド C++ ユーザーに対する特別な注意 :
クリーンアップ コードは、デストラクターではなく (On)(Begin)Close (または OnAbort のどちらか一方または両方) に置いてください。
デストラクターは使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。
非参照メンバーを使用しないでください。使用すると、コンパイラが IDisposable を自動生成します。
ファイナライザーを使用しないでください。使用する場合は、ビルド警告を抑制し、SuppressFinalize(Object) を呼び出し、ファイナライザー自体を (On)(Begin)Close (または OnAbort のどちらか一方または両方) から呼び出して、自動生成される IDisposable の動作をエミュレートする必要があります。
コンストラクター
プロパティ
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> オブジェクトを、現在の状態から Closed 状態に直ちに遷移させます。 (継承元 ClientBase<TChannel>) |
Close() |
ClientBase<TChannel> オブジェクトを、現在の状態から Closed 状態に遷移させます。 (継承元 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> オブジェクトを、Created 状態から Opened 状態に遷移させます。 (継承元 ClientBase<TChannel>) |
OpenAsync() |
双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。 (継承元 ClientBase<TChannel>) |
ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
明示的なインターフェイスの実装
拡張メソッド
CloseHelperAsync(ICommunicationObject, TimeSpan) |
双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。 |
OpenHelperAsync(ICommunicationObject, TimeSpan) |
双方向サービスへのチャネルを作成し、そのチャネルをコールバック オブジェクトに関連付けるために使用されます。 |
ConfigureAwait(IAsyncDisposable, Boolean) |
非同期の破棄可能から返されるタスク上での待機がどのように実行されるかを構成します。 |
適用対象
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示