SynchronizationAttribute Class
.NET Framework 3.0
Sets the synchronization value of the component. This class cannot be inherited.
Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
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
Not applicable.
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
Community Additions
ADD
Show: