共用方式為


Consistency 列舉

定義

警告

The Constrained Execution Region (CER) feature is not supported.

指定可靠性合約。

public enum class Consistency
[System.Obsolete("The Constrained Execution Region (CER) feature is not supported.", DiagnosticId="SYSLIB0004", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum Consistency
public enum Consistency
[System.Serializable]
public enum Consistency
[<System.Obsolete("The Constrained Execution Region (CER) feature is not supported.", DiagnosticId="SYSLIB0004", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type Consistency = 
type Consistency = 
[<System.Serializable>]
type Consistency = 
Public Enum Consistency
繼承
Consistency
屬性

欄位

MayCorruptAppDomain 1

在例外條件下,Common Language Runtime (CLR) 將不保證目前應用程式定義域的狀態一致性。

MayCorruptInstance 2

在例外條件下,此方法將保證限制對目前執行個體的狀態損毀。

MayCorruptProcess 0

在例外條件下,CLR 不保證狀態一致性,也就是說,該條件可能會損毀處理序。

WillNotCorruptState 3

在例外條件下,此方法保證不會損毀狀態。 (這不保證方此法將一律不會失敗;不過,這保證此類失敗將一律不會造成狀態損毀。)

範例

下列程式代碼範例示範在指定方法的限制執行區域時,列舉的使用 Consistency 方式。 此程式代碼範例是建構函式所提供較大範例的 ReliabilityContractAttribute 一部分。

[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImpl(MethodImplOptions.NoInlining)]
void StackDepth2()
{
    try
    {
        consistentLevel2 = false;
        if (depth == 2)
            Thread.Sleep(-1);
        StackDepth3();
    }
    finally
    {
        consistentLevel2 = true;
    }
}
<ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)>
<MethodImpl(MethodImplOptions.NoInlining)>
Sub StackDepth2()
   Try
      consistentLevel2 = False
      If depth = 2 Then Thread.Sleep(-1)
      StackDepth3()
   Finally
      consistentLevel2 = True
   End Try
End Sub

備註

列舉 Consistency 可用來做為 屬性的參數, ReliabilityContractAttribute 以指定指定方法的可靠性保證。

適用於

另請參閱