SynchronizationAttribute Class
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
[ComVisibleAttribute(false)] [AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] public sealed class SynchronizationAttribute : Attribute
/** @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.
using System; using System.EnterpriseServices; using System.Reflection; // References: // System.EnterpriseServices // This is equivalent to [Synchronization(SynchronizationOption.Required)]. [Synchronization] public class SynchronizationAttribute_Ctor : ServicedComponent { } [Synchronization(SynchronizationOption.Disabled)] public class SynchronizationAttribute_Ctor_SynchronizationOption : ServicedComponent { } [Synchronization(SynchronizationOption.RequiresNew)] public class SynchronizationAttribute_Value : ServicedComponent { public void ValueExample() { // Get the SynchronizationAttribute applied to the class. SynchronizationAttribute attribute = (SynchronizationAttribute)Attribute.GetCustomAttribute( this.GetType(), typeof(SynchronizationAttribute), false); // Display the value of the attribute's Value property. Console.WriteLine("SynchronizationAttribute.Value: {0}", attribute.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.