GCNotificationStatus 열거형

정의

다음 전체 가비지 수집에 대한 알림에 현재 등록에 대한 정보를 제공합니다.Provides information about the current registration for notification of the next full garbage collection.

public enum class GCNotificationStatus
public enum GCNotificationStatus
[System.Serializable]
public enum GCNotificationStatus
type GCNotificationStatus = 
Public Enum GCNotificationStatus
상속
GCNotificationStatus
특성

필드

Canceled 2

사용자가 현재 등록을 취소했습니다.The current registration was canceled by the user.

Failed 1

어떤 이유로든 알림이 실패했습니다.The notification failed for any reason.

NotApplicable 4

이 결과는 가비지 수집 알림에 대한 현재 등록이 없거나, 동시 가비지 수집이 사용되도록 설정되었거나, millisecondsTimeout 매개 변수에 대해 지정된 시간이 만료되었으며 가비지 수집 알림을 받지 못한 경우에 발생할 수 있습니다.This result can be caused by the following: there is no current registration for a garbage collection notification, concurrent garbage collection is enabled, or the time specified for the millisecondsTimeout parameter has expired and no garbage collection notification was obtained. (동시 가비지 수집을 사용하지 않도록 설정하는 방법에 대한 자세한 내용은 <gcConcurrent> 런타임 설정을 참조하세요.)(See the <gcConcurrent> runtime setting for information about how to disable concurrent garbage collection.)

Succeeded 0

알림이 성공적으로 수행되었으며 등록이 취소되지 않았습니다.The notification was successful and the registration was not canceled.

Timeout 3

millisecondsTimeout 또는 WaitForFullGCApproach(Int32)에 대해 WaitForFullGCComplete(Int32) 매개 변수로 지정된 시간이 경과되었습니다.The time specified by the millisecondsTimeout parameter for either WaitForFullGCApproach(Int32) or WaitForFullGCComplete(Int32) has elapsed.

예제

다음 예제에서는 WaitForFullGCApproach 메서드에서 GCNotificationStatus 열거형을 가져옵니다.The following example obtains a GCNotificationStatus enumeration from the WaitForFullGCApproach method. 열거가 성공적으로 반환 되 면 전체 가비지 수집에 대 한 응답으로 작업을 수행 하는 사용자 지정 메서드 OnFullGCApproachNotify를 호출 합니다.If the enumeration returns Succeeded, it calls the custom method OnFullGCApproachNotify to perform actions in response to the approaching full garbage collection. 이 코드 예제는 가비지 수집 알림 항목에 대해 제공 되는 더 큰 예제의 일부입니다.This code example is part of a larger example provided for Garbage Collection Notifications topic.

public:
    static void WaitForFullGCProc()
    {
        while (true)
        {
            // CheckForNotify is set to true and false in Main.
            while (checkForNotify)
            {
                // Check for a notification of an approaching collection.
                GCNotificationStatus s = GC::WaitForFullGCApproach();
                if (s == GCNotificationStatus::Succeeded)
                {
                    Console::WriteLine("GC Notifiction raised.");
                    OnFullGCApproachNotify();
                }
                else if (s == GCNotificationStatus::Canceled)
                {
                    Console::WriteLine("GC Notification cancelled.");
                    break;
                }
                else
                {
                    // This can occur if a timeout period
                    // is specified for WaitForFullGCApproach(Timeout)
                    // or WaitForFullGCComplete(Timeout)
                    // and the time out period has elapsed.
                    Console::WriteLine("GC Notification not applicable.");
                    break;
                }

                // Check for a notification of a completed collection.
                s = GC::WaitForFullGCComplete();
                if (s == GCNotificationStatus::Succeeded)
                {
                    Console::WriteLine("GC Notification raised.");
                    OnFullGCCompleteEndNotify();
                }
                else if (s == GCNotificationStatus::Canceled)
                {
                    Console::WriteLine("GC Notification cancelled.");
                    break;
                }
                else
                {
                    // Could be a time out.
                    Console::WriteLine("GC Notification not applicable.");
                    break;
                }
            }


            Thread::Sleep(500);
            // FinalExit is set to true right before
            // the main thread cancelled notification.
            if (finalExit)
            {
                break;
            }
        }
    }
public static void WaitForFullGCProc()
{
    while (true)
    {
        // CheckForNotify is set to true and false in Main.
        while (checkForNotify)
        {
            // Check for a notification of an approaching collection.
            GCNotificationStatus s = GC.WaitForFullGCApproach();
            if (s == GCNotificationStatus.Succeeded)
            {
                Console.WriteLine("GC Notification raised.");
                OnFullGCApproachNotify();
            }
            else if (s == GCNotificationStatus.Canceled)
            {
                Console.WriteLine("GC Notification cancelled.");
                break;
            }
            else
            {
                // This can occur if a timeout period
                // is specified for WaitForFullGCApproach(Timeout) 
                // or WaitForFullGCComplete(Timeout)  
                // and the time out period has elapsed. 
                Console.WriteLine("GC Notification not applicable.");
                break;
            }

            // Check for a notification of a completed collection.
            GCNotificationStatus status = GC.WaitForFullGCComplete();
            if (status == GCNotificationStatus.Succeeded)
            {
                Console.WriteLine("GC Notification raised.");
                OnFullGCCompleteEndNotify();
            }
            else if (status == GCNotificationStatus.Canceled)
            {
                Console.WriteLine("GC Notification cancelled.");
                break;
            }
            else
            {
                // Could be a time out.
                Console.WriteLine("GC Notification not applicable.");
                break;
            }
        }

        Thread.Sleep(500);
        // FinalExit is set to true right before  
        // the main thread cancelled notification.
        if (finalExit)
        {
            break;
        }
    }
}
Public Shared Sub WaitForFullGCProc()

    While True
        ' CheckForNotify is set to true and false in Main.

        While checkForNotify
            ' Check for a notification of an approaching collection.
            Dim s As GCNotificationStatus = GC.WaitForFullGCApproach
            If (s = GCNotificationStatus.Succeeded) Then
                Console.WriteLine("GC Notification raised.")
                OnFullGCApproachNotify()
            ElseIf (s = GCNotificationStatus.Canceled) Then
                Console.WriteLine("GC Notification cancelled.")
                Exit While
            Else
                ' This can occur if a timeout period
                ' is specified for WaitForFullGCApproach(Timeout) 
                ' or WaitForFullGCComplete(Timeout)  
                ' and the time out period has elapsed. 
                Console.WriteLine("GC Notification not applicable.")
                Exit While
            End If

            ' Check for a notification of a completed collection.
            s = GC.WaitForFullGCComplete
            If (s = GCNotificationStatus.Succeeded) Then
                Console.WriteLine("GC Notifiction raised.")
                OnFullGCCompleteEndNotify()
            ElseIf (s = GCNotificationStatus.Canceled) Then
                Console.WriteLine("GC Notification cancelled.")
                Exit While
            Else
                ' Could be a time out.
                Console.WriteLine("GC Notification not applicable.")
                Exit While
            End If

        End While
        Thread.Sleep(500)
        ' FinalExit is set to true right before  
        ' the main thread cancelled notification.
        If finalExit Then
            Exit While
        End If

    End While
End Sub

설명

RegisterForFullGCNotification 메서드를 사용 하 여 전체 가비지 수집 알림에 등록 합니다.Use the RegisterForFullGCNotification method to register for a full garbage collection notification. 그런 다음 WaitForFullGCApproach 메서드나 WaitForFullGCComplete 메서드를 사용 하 여 알림 상태를 포함 하는 GCNotificationStatus 열거형을 반환 합니다.Then use the WaitForFullGCApproach method or the WaitForFullGCComplete method to return a GCNotificationStatus enumeration that contains the status of the notification.

적용 대상

추가 정보