GCNotificationStatus GCNotificationStatus GCNotificationStatus GCNotificationStatus Enum

Definizione

Fornisce informazioni sulla registrazione corrente per la notifica della successiva Garbage Collection completa.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
Ereditarietà
GCNotificationStatusGCNotificationStatusGCNotificationStatusGCNotificationStatus
Attributi

Campi

Canceled Canceled Canceled Canceled 2

La registrazione corrente è stata annullata dall'utente.The current registration was canceled by the user.

Failed Failed Failed Failed 1

La notifica non è riuscita per un motivo qualsiasi.The notification failed for any reason.

NotApplicable NotApplicable NotApplicable NotApplicable 4

Questo risultato può essere causato dalle condizioni seguenti: non esistono registrazioni correnti per una notifica di Garbage Collection, la Garbage Collection simultanea è abilitata o il tempo specificato per il parametro millisecondsTimeout è scaduto e non sono state ottenute notifiche di Garbage Collection.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. Vedere l'impostazione di runtime <gcConcurrent> per informazioni su come disabilitare la Garbage Collection simultanea.(See the <gcConcurrent> runtime setting for information about how to disable concurrent garbage collection.)

Succeeded Succeeded Succeeded Succeeded 0

La notifica è riuscita e la registrazione non è stata annullata.The notification was successful and the registration was not canceled.

Timeout Timeout Timeout Timeout 3

Il tempo specificato dal parametro millisecondsTimeout per WaitForFullGCApproach(Int32) o WaitForFullGCComplete(Int32) è trascorso.The time specified by the millisecondsTimeout parameter for either WaitForFullGCApproach(Int32) or WaitForFullGCComplete(Int32) has elapsed.

Esempi

L'esempio seguente ottiene una GCNotificationStatus enumerazione dal WaitForFullGCApproach (metodo).The following example obtains a GCNotificationStatus enumeration from the WaitForFullGCApproach method. Se l'enumerazione restituisce Succeeded, chiama il metodo personalizzato OnFullGCApproachNotify per eseguire azioni in risposta all'imminente operazione completa di garbage collection.If the enumeration returns Succeeded, it calls the custom method OnFullGCApproachNotify to perform actions in response to the approaching full garbage collection. Questo esempio di codice è parte di un esempio più esaustivo disponibile per notifiche di Garbage Collection argomento.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

Commenti

Usare il RegisterForFullGCNotification metodo per la registrazione per una notifica di operazione completa di garbage collection.Use the RegisterForFullGCNotification method to register for a full garbage collection notification. Quindi usare il WaitForFullGCApproach metodo o il WaitForFullGCComplete metodo restituisca un GCNotificationStatus enumerazione che contiene lo stato della notifica.Then use the WaitForFullGCApproach method or the WaitForFullGCComplete method to return a GCNotificationStatus enumeration that contains the status of the notification.

Si applica a

Vedi anche