GCNotificationStatus GCNotificationStatus GCNotificationStatus GCNotificationStatus Enum

정의

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

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

필드

Canceled Canceled Canceled Canceled 2

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

Failed Failed Failed Failed 1

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

NotApplicable NotApplicable NotApplicable 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 Succeeded Succeeded Succeeded 0

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

Timeout Timeout Timeout Timeout 3

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

예제

다음 예에서는 GCNotificationStatus 열거형을 WaitForFullGCApproach 메서드.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.

적용 대상

추가 정보