GC::EndNoGCRegion Method ()

.NET Framework (current version)
 

Ends the no GC region latency mode.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
[SecurityCriticalAttribute]
static void EndNoGCRegion()

Exception Condition
InvalidOperationException

The garbage collector is not in no GC region latency mode. See the Remarks section for more information.

-or-

The no GC region latency mode was ended previously because a garbage collection was induced.

-or-

A memory allocation exceeded the amount specified in the call to the TryStartNoGCRegion method.

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:

No code example is currently available or this language may not be supported.

.NET Framework
Available since 4.6
Return to top
Show: