GCNotificationStatus Sabit listesi

Tanım

Sonraki tam çöp toplama bildirimi için geçerli kayıt hakkında bilgi sağlar.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 = 
[<System.Serializable>]
type GCNotificationStatus = 
Public Enum GCNotificationStatus
Devralma
GCNotificationStatus
Öznitelikler

Alanlar

Canceled 2

Geçerli kayıt Kullanıcı tarafından iptal edildi.The current registration was canceled by the user.

Failed 1

Bildirim herhangi bir nedenden dolayı başarısız oldu.The notification failed for any reason.

NotApplicable 4

Bu sonuca şunlar neden olabilir: çöp toplama bildirimi için geçerli kayıt yok, eş zamanlı çöp toplama etkin veya parametre için belirtilen saatin millisecondsTimeout süresi doldu ve çöp toplama bildirimi alınamadı.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. (Eş zamanlı atık toplamayı devre dışı bırakma hakkında bilgi için bkz. < gcConcurrent > Runtime ayarı.)(See the <gcConcurrent> runtime setting for information about how to disable concurrent garbage collection.)

Succeeded 0

Bildirim başarılı oldu ve kayıt iptal edildi.The notification was successful and the registration was not canceled.

Timeout 3

Ya millisecondsTimeout da için parametresi tarafından belirtilen süre WaitForFullGCApproach(Int32) WaitForFullGCComplete(Int32) geçti.The time specified by the millisecondsTimeout parameter for either WaitForFullGCApproach(Int32) or WaitForFullGCComplete(Int32) has elapsed.

Örnekler

Aşağıdaki örnek, yönteminden bir GCNotificationStatus numaralandırma edinir WaitForFullGCApproach .The following example obtains a GCNotificationStatus enumeration from the WaitForFullGCApproach method. Sabit Listesi başarılı döndürürse, OnFullGCApproachNotify yaklaşan tam atık toplamaya yanıt olarak eylem gerçekleştirmek için özel yöntemi çağırır.If the enumeration returns Succeeded, it calls the custom method OnFullGCApproachNotify to perform actions in response to the approaching full garbage collection. Bu kod örneği, çöp toplama bildirimleri konusunda sağlanmış daha büyük bir örneğin bir parçasıdır.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

Açıklamalar

RegisterForFullGCNotificationTam çöp toplama bildirimine kaydolmak için yöntemini kullanın.Use the RegisterForFullGCNotification method to register for a full garbage collection notification. Ardından, WaitForFullGCApproach WaitForFullGCComplete bildirim durumunu içeren bir numaralandırma döndürmek için yöntemini veya yöntemini kullanın GCNotificationStatus .Then use the WaitForFullGCApproach method or the WaitForFullGCComplete method to return a GCNotificationStatus enumeration that contains the status of the notification.

Şunlara uygulanır

Ayrıca bkz.