SynchronizationAttribute Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Définit la valeur de synchronisation du composant. Cette classe ne peut pas être héritée.
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
- Héritage
- Attributs
Exemples
L’exemple de code suivant illustre l’utilisation du 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);
}
}
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
Remarques
L’activation de transaction et juste-à-temps (JIT) active automatiquement la synchronisation.
Pour plus d’informations sur l’utilisation d’attributs, consultez Attributs.
L’application SynchronizationAttribute à un objet lié au contexte entraîne la création d’un handle d’attente et d’un événement de réinitialisation automatique, qui ne sont pas collectés de manière déterministe. Par conséquent, vous ne devez pas créer un grand nombre d’objets liés au contexte marqués avec le SynchronizationAttribute délai imparti.
Constructeurs
| Nom | Description |
|---|---|
| SynchronizationAttribute() |
Initialise une nouvelle instance de la SynchronizationAttribute classe avec la valeur par défaut SynchronizationOption. |
| SynchronizationAttribute(SynchronizationOption) |
Initialise une nouvelle instance de la SynchronizationAttribute classe avec le fichier spécifié SynchronizationOption. |
Propriétés
| Nom | Description |
|---|---|
| TypeId |
En cas d’implémentation dans une classe dérivée, obtient un identificateur unique pour cette Attribute. (Hérité de Attribute) |
| Value |
Obtient le paramètre actuel de la Value propriété. |
Méthodes
| Nom | Description |
|---|---|
| Equals(Object) |
Retourne une valeur qui indique si cette instance est égale à un objet spécifié. (Hérité de Attribute) |
| GetHashCode() |
Retourne le code de hachage pour cette instance. (Hérité de Attribute) |
| GetType() |
Obtient la Type de l’instance actuelle. (Hérité de Object) |
| IsDefaultAttribute() |
En cas de substitution dans une classe dérivée, indique si la valeur de cette instance est la valeur par défaut de la classe dérivée. (Hérité de Attribute) |
| Match(Object) |
En cas de substitution dans une classe dérivée, retourne une valeur qui indique si cette instance est égale à un objet spécifié. (Hérité de Attribute) |
| MemberwiseClone() |
Crée une copie superficielle du Objectactuel. (Hérité de Object) |
| ToString() |
Retourne une chaîne qui représente l’objet actuel. (Hérité de Object) |
Implémentations d’interfaces explicites
| Nom | Description |
|---|---|
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) |
Mappe un jeu de noms avec un jeu correspondant d'identificateurs de dispatch. (Hérité de Attribute) |
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) |
Récupère les informations de type d’un objet, qui peuvent être utilisées pour obtenir les informations de type d’une interface. (Hérité de Attribute) |
| _Attribute.GetTypeInfoCount(UInt32) |
Récupère le nombre d'interfaces d'informations de type fourni par un objet (0 ou 1). (Hérité de Attribute) |
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) |
Fournit l’accès aux propriétés et méthodes exposées par un objet. (Hérité de Attribute) |