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 =
[<System.Serializable>]
type GCNotificationStatus =
Public Enum GCNotificationStatus
- 継承
- 属性
フィールド
Canceled | 2 | 現在の登録はユーザーによって取り消されました。The current registration was canceled by the user. |
Failed | 1 | 何らかの理由で通知が失敗しました。The notification failed for any reason. |
NotApplicable | 4 | この結果は、ガベージ コレクションの通知が現在登録されていない、同時実行ガベージ コレクションが有効になっている、または |
Succeeded | 0 | 通知が成功し、登録は取り消されませんでした。The notification was successful and the registration was not canceled. |
Timeout | 3 | WaitForFullGCApproach(Int32) または WaitForFullGCComplete(Int32) の |
例
次の例では、 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.