GC.WaitForFullGCApproach 메서드

정의

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 반환합니다.

오버로드

WaitForFullGCApproach()

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 반환합니다.

WaitForFullGCApproach(Int32)

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 지정된 제한 시간 내에 반환합니다.

WaitForFullGCApproach(TimeSpan)

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 지정된 제한 시간 내에 반환합니다.

WaitForFullGCApproach()

Source:
GC.CoreCLR.cs
Source:
GC.CoreCLR.cs
Source:
GC.CoreCLR.cs

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 반환합니다.

public:
 static GCNotificationStatus WaitForFullGCApproach();
public static GCNotificationStatus WaitForFullGCApproach ();
[System.Security.SecurityCritical]
public static GCNotificationStatus WaitForFullGCApproach ();
static member WaitForFullGCApproach : unit -> GCNotificationStatus
[<System.Security.SecurityCritical>]
static member WaitForFullGCApproach : unit -> GCNotificationStatus
Public Shared Function WaitForFullGCApproach () As GCNotificationStatus

반환

등록된 가비지 수집 알림의 상태입니다.

특성

예제

다음 예제에서는이 메서드를 사용 하 여 전체 차단 가비지 수집이 접근 하는지 여부를 확인 하는 방법을 보여 줍니다. 알림의 상태 일 Succeeded때마다 접근 컬렉션에 대한 응답으로 작업을 수행하기 위해 사용자 메서드 OnFullGCApproachNotify 가 호출됩니다. 이 코드 예제는 가비지 수집 알림 항목에 제공된 더 큰 예제의 일부입니다.

// 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 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 an approaching collection.
match GC.WaitForFullGCApproach() with
| GCNotificationStatus.Succeeded ->
    printfn "GC Notification raised."
    onFullGCApproachNotify ()
    // Check for a notification of a completed collection.
    match GC.WaitForFullGCComplete() with
    | GCNotificationStatus.Succeeded ->
        printfn "GC Notification raised."
        onFullGCCompleteEndNotify ()
    | GCNotificationStatus.Canceled ->
        printfn "GC Notification cancelled."
        broken <- true
    | _ ->
        // Could be a time out.
        printfn "GC Notification not applicable."
        broken <- true
| GCNotificationStatus.Canceled ->
    printfn "GC Notification cancelled."
    broken <- true
| _ ->
    // This can occur if a timeout period
    // is specified for WaitForFullGCApproach(Timeout)
    // or WaitForFullGCComplete(Timeout)
    // and the time out period has elapsed.
    printfn "GC Notification not applicable."
    broken <- true
' 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

설명

이 메서드에서 반환된 GCNotificationStatus 열거형을 사용하여 메서드를 사용하여 RegisterForFullGCNotification 등록된 현재 가비지 수집 알림의 상태 확인합니다. 메서드를 WaitForFullGCComplete 사용하여 전체 가비지 수집이 완료되었는지 여부를 확인할 수도 있습니다.

열거형이 를 반환 Succeeded하면 추가 개체가 할당되지 않도록 방지하고 메서드를 사용하여 컬렉션을 직접 Collect 유도하는 등의 작업을 수행할 수 있습니다. 알림은 전체 가비지 수집이 발생한다고 보장할 수 없으며 전체 가비지 수집이 발생할 수 있는 임계값에 도달한 조건만 보장합니다.

이 메서드는 가비지 수집 알림을 가져올 때까지 무기한 대기합니다. 알림을 가져올 수 없는 경우 메서드가 반환할 시간 제한 기간을 지정하려면 메서드 오버로드를 GC.WaitForFullGCApproach(Int32) 사용합니다. 시간 초과를 지정하지 않고 이 메서드를 호출하는 경우 기본 설정보다 오래 기다리는 경우 메서드를 호출 CancelFullGCNotification 할 수 있습니다.

전체 가비지 수집이 있는지 확인하려면 메서드를 WaitForFullGCComplete 호출하여 이 메서드를 따라야 합니다. 이 메서드만 호출하면 확정되지 않은 결과가 발생합니다.

추가 정보

적용 대상

WaitForFullGCApproach(Int32)

Source:
GC.CoreCLR.cs
Source:
GC.CoreCLR.cs
Source:
GC.CoreCLR.cs

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 지정된 제한 시간 내에 반환합니다.

public:
 static GCNotificationStatus WaitForFullGCApproach(int millisecondsTimeout);
public static GCNotificationStatus WaitForFullGCApproach (int millisecondsTimeout);
[System.Security.SecurityCritical]
public static GCNotificationStatus WaitForFullGCApproach (int millisecondsTimeout);
static member WaitForFullGCApproach : int -> GCNotificationStatus
[<System.Security.SecurityCritical>]
static member WaitForFullGCApproach : int -> GCNotificationStatus
Public Shared Function WaitForFullGCApproach (millisecondsTimeout As Integer) As GCNotificationStatus

매개 변수

millisecondsTimeout
Int32

알림 상태를 가져올 때까지 기다릴 시간의 길이입니다. 무한정 기다리려면 -1을 지정합니다.

반환

등록된 가비지 수집 알림의 상태입니다.

특성

예외

millisecondsTimeout 는 음수가 아니거나 Int32.MaxValue 또는 -1보다 작거나 같아야 합니다.

설명

이 메서드에서 반환된 GCNotificationStatus 열거형을 사용하여 메서드를 사용하여 RegisterForFullGCNotification 등록된 현재 가비지 수집 알림의 상태 확인합니다. 메서드를 WaitForFullGCComplete 사용하여 전체 가비지 수집이 완료되었는지 여부를 확인할 수도 있습니다.

이 메서드는 에 지정된 값에 관계없이 가비지 수집 알림 상태 가져올 때마다 즉시 반환됩니다millisecondsTimeout. 시간 초과 전에 millisecondsTimeout 가비지 수집 알림 상태 가져오지 않으면 이 메서드는 를 반환합니다NotApplicable.

열거형이 를 반환 Succeeded하면 추가 개체가 할당되지 않도록 방지하고 메서드를 사용하여 컬렉션을 직접 Collect 유도하는 등의 작업을 수행할 수 있습니다. 알림은 전체 가비지 수집이 발생한다고 보장할 수 없으며 전체 가비지 수집이 발생할 수 있는 임계값에 도달한 조건만 보장합니다.

시간 제한 기간이 경과될 때까지 기다릴 수 없는 경우 메서드를 호출 CancelFullGCNotification 할 수 있습니다.

전체 가비지 수집이 있는지 확인하려면 메서드를 WaitForFullGCComplete 호출하여 이 메서드를 따라야 합니다. 이 메서드만 호출하면 확정되지 않은 결과가 발생합니다.

추가 정보

적용 대상

WaitForFullGCApproach(TimeSpan)

Source:
GC.cs
Source:
GC.cs
Source:
GC.cs

공용 언어 런타임에 의한 전체 차단 가비지 컬렉션이 임박하고 있는지 여부를 확인하기 위한 등록된 알림의 상태를 지정된 제한 시간 내에 반환합니다.

public:
 static GCNotificationStatus WaitForFullGCApproach(TimeSpan timeout);
public static GCNotificationStatus WaitForFullGCApproach (TimeSpan timeout);
static member WaitForFullGCApproach : TimeSpan -> GCNotificationStatus
Public Shared Function WaitForFullGCApproach (timeout As TimeSpan) As GCNotificationStatus

매개 변수

timeout
TimeSpan

전체 GC 접근 방식을 기다리는 시간 제한

반환

등록된 전체 GC 알림의 상태

적용 대상