SynchronizationAttribute Class
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
'Declaration <ComVisibleAttribute(False)> _ <AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _ Public NotInheritable Class SynchronizationAttribute Inherits Attribute 'Usage Dim instance As SynchronizationAttribute
/** @attribute ComVisibleAttribute(false) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ public final class SynchronizationAttribute extends Attribute
ComVisibleAttribute(false) AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) public final class SynchronizationAttribute extends Attribute
Both transaction and just-in-time (JIT) activation enable synchronization automatically.
For more information about using attributes, see Extending Metadata Using Attributes.
Applying SynchronizationAttribute to a context-bound object results in the creation of a wait handle and auto reset event, which are not deterministically garbage collected. Therefore, you should not create a large number of context-bound objects marked with the SynchronizationAttribute within a short time period.
The following code example demonstrates the use of the SynchronizationAttribute type.
Imports System Imports System.EnterpriseServices Imports System.Reflection ' References: ' System.EnterpriseServices ' This is equivalent to [Synchronization(SynchronizationOption.Required)]. <Synchronization()> _ Public Class SynchronizationAttribute_Ctor Inherits ServicedComponent End Class 'SynchronizationAttribute_Ctor <Synchronization(SynchronizationOption.Disabled)> _ Public Class SynchronizationAttribute_Ctor_SynchronizationOption Inherits ServicedComponent End Class 'SynchronizationAttribute_Ctor_SynchronizationOption <Synchronization(SynchronizationOption.RequiresNew)> _ Public Class SynchronizationAttribute_Value Inherits ServicedComponent Public Sub ValueExample() ' Get the SynchronizationAttribute applied to the class. Dim attribute As SynchronizationAttribute = CType(Attribute.GetCustomAttribute(Me.GetType(), GetType(SynchronizationAttribute), False), SynchronizationAttribute) ' Display the value of the attribute's Value property. MsgBox("SynchronizationAttribute.Value: " & attribute.Value) End Sub 'ValueExample End Class 'SynchronizationAttribute_Value
import System.*;
import System.EnterpriseServices.*;
import System.Reflection.*;
// References:
// System.EnterpriseServices
// This is equivalent to [Synchronization(SynchronizationOption.Required)].
/** @attribute Synchronization()
*/
public class SynchronizationAttribute_Ctor extends ServicedComponent
{
} //SynchronizationAttribute_Ctor
/** @attribute Synchronization(SynchronizationOption.Disabled)
*/
public class SynchronizationAttribute_Ctor_SynchronizationOption
extends ServicedComponent
{
} //SynchronizationAttribute_Ctor_SynchronizationOption
/** @attribute Synchronization(SynchronizationOption.RequiresNew)
*/
public class SynchronizationAttribute_Value extends ServicedComponent
{
public void ValueExample()
{
// Get the SynchronizationAttribute applied to the class.
SynchronizationAttribute attribute = (SynchronizationAttribute)(
Attribute.GetCustomAttribute(this.GetType(),
SynchronizationAttribute.class.ToType(), false));
// Display the value of the attribute's Value property.
Console.WriteLine("SynchronizationAttribute.Value: {0}",
attribute.get_Value());
} //ValueExample
} //SynchronizationAttribute_Value
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.