GC.EndNoGCRegion 方法

定義

結束無 GC 區域延遲模式。Ends the no GC region latency mode.

public:
 static void EndNoGCRegion();
public static void EndNoGCRegion ();
[System.Security.SecurityCritical]
public static void EndNoGCRegion ();
static member EndNoGCRegion : unit -> unit
[<System.Security.SecurityCritical>]
static member EndNoGCRegion : unit -> unit
Public Shared Sub EndNoGCRegion ()
屬性

例外狀況

記憶體回收行程不在無 GC 區域延遲模式下。The garbage collector is not in no GC region latency mode.

-或--or- 無 GC 區域延遲模式之前已結束,因為已包含記憶體回收。The no GC region latency mode was ended previously because a garbage collection was induced.

-或--or- 記憶體配置超過 TryStartNoGCRegion(Int64) 方法呼叫中所指定的數量。A memory allocation exceeded the amount specified in the call to the TryStartNoGCRegion(Int64) method.

備註

EndNoGCRegion InvalidOperationException 如果垃圾收集行程不是無 GC 區域延遲模式,方法會擲回。The EndNoGCRegion method throws an InvalidOperationException if the garbage collector is not in no GC region latency mode. 這會發生在下列任何情況下:This occurs under any of the following conditions:

您可以使用如下所示的程式碼,防止例外狀況發生:You can prevent an exception for any of these reasons by using code such as the following:

if (GCSettings.LatencyMode == GCLatencyMode.NoGCRegion)
   GC.EndNoGCRegion();
If GCSettings.LatencyMode = GCLatencyMode.NoGCRegion Then
   GC.EndNoGCRegion()
End If

適用於

另請參閱