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.

適用対象

こちらもご覧ください