Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 ILogicalThreadAffinative Interface
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ILogicalThreadAffinative Interface

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

Namespace:  System.Runtime.Remoting.Messaging
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
<ComVisibleAttribute(True)> _
Public Interface ILogicalThreadAffinative
Visual Basic (Usage)
Dim instance As ILogicalThreadAffinative
C#
[ComVisibleAttribute(true)]
public interface ILogicalThreadAffinative
Visual C++
[ComVisibleAttribute(true)]
public interface class ILogicalThreadAffinative
JScript
public interface ILogicalThreadAffinative

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.

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.

Visual Basic
<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 'New

End Class 'LogicalCallContextData
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;
   }
}
Visual C++
[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;
   }

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

public:
    __property String* get_numOfAccesses()
    {
        return String::Format(S"The identity of {0} has been accessed {1} times.", 
            _principal->Identity->Name, 
            __box(_nAccesses));
    }

public:
    __property IPrincipal* get_Principal()
    {
        _nAccesses ++;
        return _principal;
    }

public:
    LogicalCallContextData(IPrincipal* p) 
    {
        _nAccesses = 0;
        _principal = p;
    }
};

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker