Export (0) Print
Expand All

SynchronizationAttribute Class

Enforces a synchronization domain for the current context and all contexts that share the same instance.

System.Object
  System.Attribute
    System.Runtime.Remoting.Contexts.ContextAttribute
      System.Runtime.Remoting.Contexts.SynchronizationAttribute

Namespace:  System.Runtime.Remoting.Contexts
Assembly:  mscorlib (in mscorlib.dll)

[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
[<AttributeUsageAttribute(AttributeTargets.Class)>]
[<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags = SecurityPermissionFlag.Infrastructure)>]
type SynchronizationAttribute =  
    class 
        inherit ContextAttribute 
        interface IContributeServerContextSink 
        interface IContributeClientContextSink 
    end

The SynchronizationAttribute type exposes the following members.

  NameDescription
Public methodSynchronizationAttribute()Initializes a new instance of the SynchronizationAttribute class with default values.
Public methodSynchronizationAttribute(Boolean)Initializes a new instance of the SynchronizationAttribute class with a Boolean value indicating whether reentry is required.
Public methodSynchronizationAttribute(Int32)Initializes a new instance of the SynchronizationAttribute class with a flag indicating the behavior of the object to which this attribute is applied.
Public methodSynchronizationAttribute(Int32, Boolean)Initializes a new instance of the SynchronizationAttribute class with a flag indicating the behavior of the object to which this attribute is applied, and a Boolean value indicating whether reentry is required.
Top

  NameDescription
Public propertyIsReEntrantGets or sets a Boolean value indicating whether reentry is required.
Public propertyLockedGets or sets a Boolean value indicating whether the Context implementing this instance of SynchronizationAttribute is locked.
Public propertyNameInfrastructure. Gets the name of the context attribute. (Inherited from ContextAttribute.)
Public propertyTypeIdWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)
Top

  NameDescription
Public methodEqualsInfrastructure. Returns a Boolean value indicating whether this instance is equal to the specified object. (Inherited from ContextAttribute.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFreezeInfrastructure. Called when the context is frozen. (Inherited from ContextAttribute.)
Public methodGetClientContextSinkCreates a CallOut sink and chains it in front of the provided chain of sinks at the context boundary on the client end of a remoting call.
Public methodGetHashCodeInfrastructure. Returns the hashcode for this instance of ContextAttribute. (Inherited from ContextAttribute.)
Public methodGetPropertiesForNewContextAdds the Synchronized context property to the specified IConstructionCallMessage. (Overrides ContextAttribute.GetPropertiesForNewContext(IConstructionCallMessage).)
Public methodGetServerContextSinkCreates a synchronized dispatch sink and chains it in front of the provided chain of sinks at the context boundary on the server end of a remoting call.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsContextOKReturns a Boolean value indicating whether the context parameter meets the context attribute's requirements. (Overrides ContextAttribute.IsContextOK(Context, IConstructionCallMessage).)
Public methodIsDefaultAttributeWhen overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public methodIsNewContextOKInfrastructure. Returns a Boolean value indicating whether the context property is compatible with the new context. (Inherited from ContextAttribute.)
Public methodMatchWhen overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Protected fieldAttributeNameInfrastructure. Indicates the name of the context attribute. (Inherited from ContextAttribute.)
Public fieldStatic memberNOT_SUPPORTEDIndicates that the class to which this attribute is applied cannot be created in a context that has synchronization. This field is constant.
Public fieldStatic memberREQUIREDIndicates that the class to which this attribute is applied must be created in a context that has synchronization. This field is constant.
Public fieldStatic memberREQUIRES_NEWIndicates that the class to which this attribute is applied must be created in a context with a new instance of the synchronization property each time. This field is constant.
Public fieldStatic memberSUPPORTEDIndicates that the class to which this attribute is applied is not dependent on whether the context has synchronization. This field is constant.
Top

  NameDescription
Explicit interface implemetationPrivate method_Attribute.GetIDsOfNamesMaps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoRetrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.GetTypeInfoCountRetrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method_Attribute.InvokeProvides access to properties and methods exposed by an object. (Inherited from Attribute.)
Top

When this attribute is applied to an object, only one thread can be executing in all contexts that share an instance of this property. This is done by contributing sinks that intercept and serialize incoming calls for the respective contexts. If the property is marked for reentry, then callouts are intercepted too. The callout interception allows other waiting threads to enter the synchronization domain for maximal throughput.

NoteNote

There are two classes named SynchronizationAttribute : one in the System.Runtime.Remoting.Contexts namespace, and the other in the System.EnterpriseServices namespace. The System.EnterpriseServices.SynchronizationAttribute class supports only synchronous calls, and can be used only with serviced components. (For more information on serviced components, see [<topic://cpconservicedcomponentoverview>].) The System.Runtime.Remoting.Contexts.SynchronizationAttribute supports both synchronous and asynchronous calls, and can be used only with context bound objects. (For more information on context bound objects, see the ContextBoundObject class.)

NoteNote

This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands.

The following code example demonstrates the use of the SynchronizationAttribute. For the complete example code, see the example for the AsyncResult class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft