SynchronizationAttribute Klasse

Definition

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

public ref class SynchronizationAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)]
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class SynchronizationAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, Inherited=true)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
type SynchronizationAttribute = class
    inherit Attribute
Public NotInheritable Class SynchronizationAttribute
Inherits Attribute
Vererbung
SynchronizationAttribute
Attribute

Beispiele

Im folgenden Codebeispiel wird die Verwendung des Typs SynchronizationAttribute veranschaulicht.

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);
    }
}
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

<Synchronization(SynchronizationOption.Disabled)>  _
Public Class SynchronizationAttribute_Ctor_SynchronizationOption
    Inherits ServicedComponent
End Class

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

Hinweise

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

Weitere Informationen zur Verwendung von Attributen finden Sie unter Attribute.

Das Anwenden auf SynchronizationAttribute ein kontextgebundenes Objekt führt zur Erstellung eines Wartehandles und eines Ereignisses zum automatischen Zurücksetzen, die nicht deterministisch gesammelter Müll sind. Daher sollten Sie nicht innerhalb eines kurzen Zeitraums eine große Anzahl von kontextgebundenen Objekten erstellen, die mit markiert SynchronizationAttribute sind.

Konstruktoren

SynchronizationAttribute()

Initialisiert eine neue Instanz der SynchronizationAttribute-Klasse mit der Standard-SynchronizationOption.

SynchronizationAttribute(SynchronizationOption)

Initialisiert eine neue Instanz der SynchronizationAttribute-Klasse mit der angegebenen SynchronizationOption.

Eigenschaften

TypeId

Ruft bei Implementierung in einer abgeleiteten Klasse einen eindeutigen Bezeichner für dieses Attribute ab.

(Geerbt von Attribute)
Value

Ruft die aktuelle Einstellung der Value-Eigenschaft ab.

Methoden

Equals(Object)

Gibt einen Wert zurück, der angibt, ob diese Instanz gleich einem angegebenen Objekt ist.

(Geerbt von Attribute)
GetHashCode()

Gibt den Hashcode für diese Instanz zurück.

(Geerbt von Attribute)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
IsDefaultAttribute()

Gibt beim Überschreiben in einer abgeleiteten Klasse an, ob der Wert der Instanz der Standardwert für die abgeleitete Klasse ist.

(Geerbt von Attribute)
Match(Object)

Beim Überschreiben in einer abgeleiteten Klasse wird ein Wert zurückgegeben, der angibt, ob diese Instanz einem bestimmten Objekt entspricht.

(Geerbt von Attribute)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Explizite Schnittstellenimplementierungen

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Ordnet eine Reihe von Namen einer entsprechenden Reihe von Dispatchbezeichnern zu.

(Geerbt von Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Ruft die Typinformationen für ein Objekt ab, mit deren Hilfe die Typinformationen für eine Schnittstelle abgerufen werden können.

(Geerbt von Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Ruft die Anzahl der Schnittstellen mit Typinformationen ab, die von einem Objekt bereitgestellt werden (0 oder 1).

(Geerbt von Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Stellt den Zugriff auf von einem Objekt verfügbar gemachte Eigenschaften und Methoden bereit.

(Geerbt von Attribute)

Gilt für: