Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Enumeración CommunicationState

 

Publicado: octubre de 2016

Define los estados en los que un ICommunicationObject puede existir.

Espacio de nombres:   System.ServiceModel
Ensamblado:  System.ServiceModel (en System.ServiceModel.dll)

public enum CommunicationState

Nombre de miembroDescripción
Closed

Indica que el objeto de comunicación se ha cerrado y ya no se puede utilizar.

Closing

Indica que el objeto de comunicación está pasando al estado Closed.

Created

Indica que se ha creado una instancia del objeto de comunicación y se puede configurar, pero ni se puede abrir todavía ni está lista para su uso.

Faulted

Indica que el objeto de comunicación ha encontrado un error del que no se puede recuperar y debido al cual ya no se puede utilizar.

Opened

Indica que el objeto de comunicación ya está abierto y listo para su uso.

Opening

Indica que el objeto de comunicación se está pasando del estado Created al estado Opened.

This enumeration defines the states that are valid for all communication objects in the system, including channels, listeners, factories, dispatchers, and service hosts.

The methods that manage transitions between these states and the events that can be associated with them are defined in the T:System.ServiceModel.ICommunicationObject interface. The state of an object can be obtained using the P:System.ServiceModel.ICommunicationObject.State property.

There are four main states and two transient states that a communication object can occupy. The main states are:

  • Created

  • Opened

  • Closed

  • Faulted

The two transitory states that a communication object can occupy when transitioning between these main states are:

  • Opening

  • Closing

The communication object can be configured in the F:System.ServiceModel.CommunicationState.Created state. For example, its properties can be changed, and its events can be registered. No input or output can occur in this state. So messages, for example, cannot be sent or received from a channel in this state.

The F:System.ServiceModel.CommunicationState.Opening is a temporary state that the communication object enters when the M:System.ServiceModel.ICommunicationObject.Open method is invoked. Unless otherwise noted on derived classes, objects in the opening state cannot be configured. This transition state can only be entered from the F:System.ServiceModel.CommunicationState.Created state.

Objects transition to the F:System.ServiceModel.CommunicationState.Opened state when the open process completes. This transition to the F:System.ServiceModel.CommunicationState.Opened state is only valid from the F:System.ServiceModel.CommunicationState.Opening state. Unless otherwise noted on derived classes, the configuration of the object is now disabled. At this point, the object is fully usable for message transfers.

The F:System.ServiceModel.CommunicationState.Closing is a temporary state that the object enters when the M:System.ServiceModel.ICommunicationObject.Close method is invoked for a graceful shutdown or the object is aborted. At this point, the object becomes (if not already) unusable. This transition is valid from any state except the F:System.ServiceModel.CommunicationState.Closed state.

The F:System.ServiceModel.CommunicationState.Closed state is equivalent to being disposed and the configuration of the object can still be inspected.

The F:System.ServiceModel.CommunicationState.Faulted state is used to indicate that the object has transitioned to a state where it can no longer be used. There are two primary scenarios where this can happen:

  • If the M:System.ServiceModel.ICommunicationObject.Open method fails for any reason, the object transitions to the faulted state.

  • If a session-based channel detects an error that it cannot recover from, it transitions to the faulted state. This can happen for instance if there is a protocol error (that is, it receives a protocol message at an invalid time) or if the remote endpoint aborts the session.

An object in the F:System.ServiceModel.CommunicationState.Faulted state is not closed and may be holding resources. The M:System.ServiceModel.ICommunicationObject.Abort method should be used to close an object that has faulted. If M:System.ServiceModel.ICommunicationObject.Close is called on an object in the F:System.ServiceModel.CommunicationState.Faulted state, a T:System.ServiceModel.CommunicationObjectFaultedException is thrown because the object cannot be gracefully closed.

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 3.0
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Volver al principio
Mostrar: