SynchronizationAttribute Classe

Definição

Define o valor de sincronização do componente. Essa classe não pode ser herdada.

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
Herança
SynchronizationAttribute
Atributos

Exemplos

O exemplo de código a seguir demonstra o uso do SynchronizationAttribute tipo.

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

Comentários

A ativação JIT (transação) e just-in-time habilita a sincronização automaticamente.

Para obter mais informações sobre como usar atributos, consulte Atributos.

SynchronizationAttribute A aplicação a um objeto associado ao contexto resulta na criação de um identificador de espera e um evento de redefinição automática, que não são coletas deterministicamente de lixo. Portanto, você não deve criar um grande número de objetos associados ao contexto marcados com o SynchronizationAttribute período curto.

Construtores

SynchronizationAttribute()

Inicializa uma nova instância da classe SynchronizationAttribute, com o SynchronizationOption padrão.

SynchronizationAttribute(SynchronizationOption)

Inicializa uma nova instância da classe SynchronizationAttribute com o SynchronizationOption especificado.

Propriedades

TypeId

Quando implementado em uma classe derivada, obtém um identificador exclusivo para este Attribute.

(Herdado de Attribute)
Value

Obtém a configuração atual da propriedade Value.

Métodos

Equals(Object)

Retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
GetHashCode()

Retorna o código hash para a instância.

(Herdado de Attribute)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
IsDefaultAttribute()

Quando substituído em uma classe derivada, indica se o valor dessa instância é o valor padrão para a classe derivada.

(Herdado de Attribute)
Match(Object)

Quando substituído em uma classe derivada, retorna um valor que indica se essa instância é igual a um objeto especificado.

(Herdado de Attribute)
MemberwiseClone()

Cria uma cópia superficial do Object atual.

(Herdado de Object)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.

(Herdado de Object)

Implantações explícitas de interface

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

Mapeia um conjunto de nomes para um conjunto correspondente de identificadores de expedição.

(Herdado de Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera as informações de tipo para um objeto, que pode ser usado para obter as informações de tipo para uma interface.

(Herdado de Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Retorna o número de interfaces de informações do tipo que um objeto fornece (0 ou 1).

(Herdado de Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornece acesso a propriedades e métodos expostos por um objeto.

(Herdado de Attribute)

Aplica-se a