Show / Hide Table of Contents

Class GCNotification

Provides a way to receive notifications from Garbage Collector asynchronously.

Inheritance
object
GCNotification
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public abstract class GCNotification

Methods

View Source

And(GCNotification)

Combines two filters using logical AND.

Declaration
public virtual GCNotification And(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

View Source

ExclusiveOr(GCNotification)

Combines two filters using logical XOR.

Declaration
public virtual GCNotification ExclusiveOr(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

View Source

Negate()

Negates this filter.

Declaration
public virtual GCNotification Negate()
Returns
Type Description
GCNotification

A new filter.

View Source

Or(GCNotification)

Combines two filters using logical OR.

Declaration
public virtual GCNotification Or(GCNotification right)
Parameters
Type Name Description
GCNotification right

The filter to be combined with this filter.

Returns
Type Description
GCNotification

A new filter.

Exceptions
Type Condition
ArgumentNullException

right is null.

View Source

Register<T>(Action<T, GCMemoryInfo>, T, bool)

Registers a callback to be executed asynchronously on approach of GC notification.

Declaration
public GCNotification.Registration Register<T>(Action<T, GCMemoryInfo> callback, T state, bool captureContext = false)
Parameters
Type Name Description
Action<T, GCMemoryInfo> callback

The callback to be executed asynchronously.

T state

The object to be passed to the callback.

bool captureContext

true to execute the callback within the captured synchronization context; otherwise, false.

Returns
Type Description
GCNotification.Registration

The object that can be used to cancel the registration.

Type Parameters
Name Description
T

The type of the state to be passed to the callback.

Remarks

The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
ArgumentNullException

callback is null.

View Source

WaitAsync(CancellationToken)

Waits for GC notification asynchronously.

Declaration
public Task<GCMemoryInfo> WaitAsync(CancellationToken token = default)
Parameters
Type Name Description
CancellationToken token

The token that can be used to cancel the notification.

Returns
Type Description
Task<GCMemoryInfo>

The information about last occurred GC.

Remarks

The result of this method must be awaited. The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

View Source

WaitAsync(TimeSpan, CancellationToken)

Waits for GC notification asynchronously.

Declaration
public Task<GCMemoryInfo> WaitAsync(TimeSpan timeout, CancellationToken token = default)
Parameters
Type Name Description
TimeSpan timeout

The time to wait for the notification.

CancellationToken token

The token that can be used to cancel the notification.

Returns
Type Description
Task<GCMemoryInfo>

The information about last occurred GC.

Remarks

The result of this method must be awaited. The suspended caller will be resumed after approach of actual GC notification. However, the delay between these two events is possible.

Exceptions
Type Condition
OperationCanceledException

The operation has been canceled.

TimeoutException

The notification did not arrive in timely manner.

Operators

View Source

operator &(GCNotification, GCNotification)

Combines two filters using logical AND.

Declaration
public static GCNotification operator &(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

View Source

operator |(GCNotification, GCNotification)

Combines two filters using logical OR.

Declaration
public static GCNotification operator |(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

View Source

operator ^(GCNotification, GCNotification)

Combines two filters using logical XOR.

Declaration
public static GCNotification operator ^(GCNotification left, GCNotification right)
Parameters
Type Name Description
GCNotification left

The first filter to combine.

GCNotification right

The second filter to combine.

Returns
Type Description
GCNotification

A new filter.

View Source

operator !(GCNotification)

Negates the filter.

Declaration
public static GCNotification operator !(GCNotification filter)
Parameters
Type Name Description
GCNotification filter

The filter to negate.

Returns
Type Description
GCNotification

A new filter.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾