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> 합니다. 두 유형 중 하나를 사용하여 이중 서비스에 연결할 수 있습니다. 이중 서비스에 대한 자세한 내용은 Duplex Services를 참조하세요.
이 클래스에서 파생되는 관리되는 C++ 사용자를 위한 특별 참고 사항:
- 소멸자가 아닌 (On)(Begin)Close(및/또는 OnAbort)에 정리 코드를 넣습니다.
- 소멸자를 방지합니다. 컴파일러가 자동으로 생성 IDisposable됩니다.
- 참조가 아닌 멤버를 사용하지 않도록 합니다. 컴파일러가 자동으로 생성 IDisposable될 수 있습니다.
- 종료자를 사용하지 않습니다. 그러나 하나를 포함하는 경우 자동 생성된 SuppressFinalize(Object) 동작을 에뮬레이트하기 위해 빌드 경고 및 호출 IDisposable 및 종료자 자체를 (On)(Begin)Close(및/또는 OnAbort)에서 표시하지 않아야 합니다.
생성자
속성
| 속성 | Description |
|---|---|
| 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>) |