ILogicalThreadAffinative ILogicalThreadAffinative ILogicalThreadAffinative ILogicalThreadAffinative Interface

Definición

Marca un objeto que se puede propagar fuera de un AppDomain en un LogicalCallContext.Marks an object that can propagate outside of an AppDomain in a LogicalCallContext.

public interface class ILogicalThreadAffinative
[System.Runtime.InteropServices.ComVisible(true)]
public interface ILogicalThreadAffinative
type ILogicalThreadAffinative = interface
Public Interface ILogicalThreadAffinative
Atributos

Ejemplos

En el ejemplo de código siguiente se muestra el ILogicalThreadAffinative uso de la interfaz para transmitir objetos principal e Identity a una ubicación remota para su identificación.The following code example demonstrates the use of the ILogicalThreadAffinative interface to transmit Principal and Identity Objects to a remote location for identification. Para ver el código de la HelloServiceClass clase utilizada en el ejemplo, vea el ejemplo para el GetData método.To view the code for the HelloServiceClass class used in the sample, see the example for the GetData method. Para ver el código de la clase de servidor que se usa en este ejemplo, vea RegisterActivatedServiceType el ejemplo de la clase.To view the code for the server class used in this sample, see example for the RegisterActivatedServiceType class. Para ver el código de la clase de cliente que se usa en el ejemplo, vea el CallContext ejemplo de la clase.To view the code for the client class used in the sample, see the example for the CallContext class.

[Serializable]
public ref class LogicalCallContextData: public ILogicalThreadAffinative
{
private:
   int _nAccesses;
   IPrincipal^ _principal;

public:

   property String^ numOfAccesses 
   {
      String^ get()
      {
         return String::Format( "The identity of {0} has been accessed {1} times.", _principal->Identity->Name, _nAccesses );
      }
   }

   property IPrincipal^ Principal 
   {
      IPrincipal^ get()
      {
         _nAccesses++;
         return _principal;
      }
   }

   LogicalCallContextData( IPrincipal^ p )
   {
      _nAccesses = 0;
      _principal = p;
   }

};
[Serializable]
public class LogicalCallContextData : ILogicalThreadAffinative
{
   int _nAccesses;
   IPrincipal _principal;

   public string numOfAccesses {
      get {
         return String.Format("The identity of {0} has been accessed {1} times.", 
                              _principal.Identity.Name, 
                              _nAccesses);
      }
   }

   public IPrincipal Principal {
      get { 
         _nAccesses ++;
         return _principal;
      }
   }
   
   public LogicalCallContextData(IPrincipal p) {
      _nAccesses = 0;
      _principal = p;
   }
}
<Serializable()> Public Class LogicalCallContextData
   Implements ILogicalThreadAffinative

   Private _nAccesses As Integer
   Private _principal As IPrincipal
   
   
   Public ReadOnly Property numOfAccesses() As String
      Get
         Return [String].Format("The identity of {0} has been accessed {1} times.", _principal.Identity.Name, _nAccesses)
      End Get
   End Property
   
   
   Public ReadOnly Property Principal() As IPrincipal
      Get
         _nAccesses += 1
         Return _principal
      End Get
   End Property
   
   
   Public Sub New(p As IPrincipal)
      _nAccesses = 0
      _principal = p
   End Sub

End Class 'LogicalCallContextData

Comentarios

Cuando se realiza una llamada de método remoto a un objeto de AppDomainotro, la CallContext clase actual genera LogicalCallContext un que viaja junto con la llamada a la ubicación remota.When a remote method call is made to an object in another AppDomain, the current CallContext class generates a LogicalCallContext that travels along with the call to the remote location. Solo los objetos que exponen la ILogicalThreadAffinative interfaz y se almacenan CallContext en se propagan AppDomainfuera de.Only objects that expose the ILogicalThreadAffinative interface and are stored in the CallContext are propagated outside the AppDomain. Los objetos que no admiten esta interfaz no se transmiten en LogicalCallContext instancias con llamadas a métodos remotos.Objects that do not support this interface are not transmitted in LogicalCallContext instances with remote method calls.

Se aplica a