DuplexClientBase<TChannel> Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Used to create a channel to a duplex service and associate that channel with a callback object.
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
The type of the channel to be created.
- Inheritance
The following example shows the use in the client of a duplex WCF client type, the SampleDuplexHelloClient
, to pass a new System.ServiceModel.InstanceContext object with the callback object to listen for callbacks.
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
Use the DuplexClientBase<TChannel> class to create a channel to a service that specifies a callback object. The DuplexClientBase<TChannel> object wraps a System.ServiceModel.DuplexChannelFactory<TChannel> object, which provides the connectivity for the WCF object. You can use either type to connect to a duplex service. For more information about duplex services, see Duplex Services.
Special note for Managed C++ users deriving from this class:
Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor.
Avoid destructors: they cause the compiler to auto-generate IDisposable
Avoid non-reference members: they can cause the compiler to auto-generate IDisposable
Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize(Object) and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated IDisposable behavior.
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, binding, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class with the specified callback object and service endpoint. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, configuration name, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, configuration name, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object and configuration name. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, binding, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class with the specified callback object and service endpoint. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, configuration name, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object, endpoint configuration name, and service endpoint address. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object and configuration name. |
Duplex |
Initializes a new instance of the DuplexClientBase<TChannel> class using the specified callback object. |
Channel |
Gets the inner channel used to send messages to variously configured service endpoints. (Inherited from ClientBase<TChannel>) |
Channel |
Gets the underlying ChannelFactory<TChannel> object. (Inherited from ClientBase<TChannel>) |
Client |
Gets the client credentials used to call an operation. (Inherited from ClientBase<TChannel>) |
Endpoint |
Gets the target endpoint for the service to which the WCF client can connect. (Inherited from ClientBase<TChannel>) |
Inner |
Gets the underlying IClientChannel implementation. (Inherited from ClientBase<TChannel>) |
Inner |
Gets the underlying IClientChannel implementation for the duplex channel. |
State |
Gets the current state of the ClientBase<TChannel> object. (Inherited from ClientBase<TChannel>) |
Abort() |
Causes the ClientBase<TChannel> object to transition immediately from its current state into the closed state. (Inherited from ClientBase<TChannel>) |
Close() |
Causes the ClientBase<TChannel> object to transition from its current state into the closed state. (Inherited from ClientBase<TChannel>) |
Close |
(Inherited from ClientBase<TChannel>) |
Create |
Returns a channel to the service associated with the callback object passed to the constructor. |
Create |
Returns a new channel to the service. (Inherited from ClientBase<TChannel>) |
Display |
Instructs the inner channel to display a user interface if one is required to initialize the channel prior to using it. (Inherited from ClientBase<TChannel>) |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
Get |
Replicates the behavior of the default keyword in C#. (Inherited from ClientBase<TChannel>) |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Invoke |
Provides support for implementing the event-based asynchronous pattern. For more information about this pattern, see Event-based Asynchronous Pattern Overview. (Inherited from ClientBase<TChannel>) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
Open() |
Causes the ClientBase<TChannel> object to transition from the created state into the opened state. (Inherited from ClientBase<TChannel>) |
To |
Returns a string that represents the current object. (Inherited from Object) |
IAsync |
(Inherited from ClientBase<TChannel>) |
ICommunication |
Begins an asynchronous operation to close the ClientBase<TChannel>. (Inherited from ClientBase<TChannel>) |
ICommunication |
Begins an asynchronous operation to close the ClientBase<TChannel> with a specified timeout. (Inherited from ClientBase<TChannel>) |
ICommunication |
Begins an asynchronous operation to open the ClientBase<TChannel> object. (Inherited from ClientBase<TChannel>) |
ICommunication |
Begins an asynchronous operation to open the ClientBase<TChannel> object within a specified interval of time. (Inherited from ClientBase<TChannel>) |
ICommunication |
Causes a communication object to transition from its current state into the closed state. (Inherited from ClientBase<TChannel>) |
ICommunication |
Causes the ClientBase<TChannel> object to transition from its current state into the closed state. (Inherited from ClientBase<TChannel>) |
ICommunication |
The event handler that is invoked when the ClientBase<TChannel> object has transitioned from its current state to the closed state. (Inherited from ClientBase<TChannel>) |
ICommunication |
The event handler that is invoked when the ClientBase<TChannel> object transitions from its current state to the closed state. (Inherited from ClientBase<TChannel>) |
ICommunication |
Completes an asynchronous operation to close the ClientBase<TChannel> object. (Inherited from ClientBase<TChannel>) |
ICommunication |
Completes an asynchronous operation to open the ClientBase<TChannel> object. (Inherited from ClientBase<TChannel>) |
ICommunication |
The event handler that is invoked when a fault occurs while performing an operation on the ClientBase<TChannel> object. (Inherited from ClientBase<TChannel>) |
ICommunication |
Causes a communication object to transition from the created state into the opened state. (Inherited from ClientBase<TChannel>) |
ICommunication |
Causes the ClientBase<TChannel> object to transition from the created state into the opened state within a specified interval of time. (Inherited from ClientBase<TChannel>) |
ICommunication |
The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state. (Inherited from ClientBase<TChannel>) |
ICommunication |
The event handler that is invoked when the ClientBase<TChannel> object transitions from the created state to the opened state. (Inherited from ClientBase<TChannel>) |
IDisposable. |
Explicit implementation of the Dispose() method. (Inherited from ClientBase<TChannel>) |
Produkt | Versjoner |
---|---|
.NET | Core 1.0, Core 1.1, 8 (package-provided) |
.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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
UWP | 10.0 |
.NET-tilbakemelding
.NET er et åpen kilde-prosjekt. Velg en kobling for å gi tilbakemelding: