ILogicalThreadAffinative Interface

Definition

Marks an object that can propagate outside of an AppDomain in a LogicalCallContext.

C#
public interface ILogicalThreadAffinative
C#
[System.Runtime.InteropServices.ComVisible(true)]
public interface ILogicalThreadAffinative
Attributes

Examples

The following code example demonstrates the use of the ILogicalThreadAffinative interface to transmit Principal and Identity Objects to a remote location for identification. To view the code for the HelloServiceClass class used in the sample, see the example for the GetData method. To view the code for the server class used in this sample, see example for the RegisterActivatedServiceType class. To view the code for the client class used in the sample, see the example for the CallContext class.

C#
[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;
   }
}

Remarks

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. Only objects that expose the ILogicalThreadAffinative interface and are stored in the CallContext are propagated outside the AppDomain. Objects that do not support this interface are not transmitted in LogicalCallContext instances with remote method calls.

Applies to

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1