Freigeben über


SynchronizationAttribute-Klasse

Legt den Synchronisierungswert der Komponente fest. Diese Klasse kann nicht vererbt werden.

Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)

Syntax

'Declaration
<ComVisibleAttribute(False)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _
Public NotInheritable Class SynchronizationAttribute
    Inherits Attribute
'Usage
Dim instance As SynchronizationAttribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] 
public sealed class SynchronizationAttribute : Attribute
[ComVisibleAttribute(false)] 
[AttributeUsageAttribute(AttributeTargets::Class, Inherited=true)] 
public ref class SynchronizationAttribute sealed : public 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

Hinweise

Sowohl die Transaktion als auch die JIT-Aktivierung (Just-in-Time) aktivieren die Synchronisierung automatisch.

Weitere Informationen über das Verwenden von Attributen finden Sie unter Erweitern von Metadaten mithilfe von Attributen.

Wenn SynchronizationAttribute auf ein kontextgebundenes Objekt angewendet wird, wird ein WaitHandle und ein Ereignis zum automatischen Zurücksetzen erstellt, bei denen keine deterministische Garbage Collection erfolgt. Deshalb sollten Sie es vermeiden, innerhalb eines kurzen Zeitraums eine große Anzahl kontextgebundener Objekte zu erstellen, die mit dem SynchronizationAttribute gekennzeichnet sind.

Beispiel

Im folgenden Codebeispiel wird die Verwendung des SynchronizationAttribute-Typs veranschaulicht.

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
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

Vererbungshierarchie

System.Object
   System.Attribute
    System.EnterpriseServices.SynchronizationAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

SynchronizationAttribute-Member
System.EnterpriseServices-Namespace