System.GC.WaitForFullGCComplete Method

Returns, in a specified time-out period, the status of a registered notification for determining whether a full, blocking garbage collection by common language the runtime has completed.

Syntax

public static GCNotificationStatus WaitForFullGCComplete (int millisecondsTimeout)

Parameters

millisecondsTimeout
The length of time to wait before a notification status can be obtained. Specify -1 to wait indefinitely.

Returns

The status of the registered garbage collection notification.

Remarks

Use the GCNotificationStatus enumeration returned by this method to determine the status of the current garbage collection notification that was registered by using the GC.RegisterForFullGCNotification(int, int) method. You can also use the GC.WaitForFullGCApproach method to determine whether a full garbage collection is imminent.

Note that this method returns immediately whenever a garbage collection notification status is obtained, regardless of the value specified by millisecondsTimeout. If a garbage collection notification status is not obtained before millisecondsTimeout times out, this method returns GCNotificationStatus.NotApplicable.

When the enumeration returns GCNotificationStatus.Succeeded, you can do tasks such as resuming work and obtaining a collection count with the GC.CollectionCount(int) property.

You can call the GC.CancelFullGCNotification method when you cannot wait for the time-out period to elapse.

This method call should be preceded with a call to the erload:System.GC.WaitForFullGCApproach method to make sure that you have had a full garbage collection. Calling this method alone can produce indeterminate results.

Requirements

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