public sealed class LowMemoryNotificationContext : IDisposable
Public NotInheritable Class LowMemoryNotificationContext
Implements IDisposable
Dim instance As LowMemoryNotificationContext
public ref class LowMemoryNotificationContext sealed : IDisposable
[<SealedAttribute>]
type LowMemoryNotificationContext =
class
interface IDisposable
end
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
<ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)>
<SecurityCritical>
Private Sub Test()
Dim computerInfo As New Microsoft.VisualBasic.Devices.ComputerInfo()
Dim minMemory As ULong = 1073741824 '1 GB
Dim action As New Action(
Sub()
Console.WriteLine("Available free physical memory is running low...")
Console.WriteLine($"Total...........: {New Filesize(computerInfo.TotalPhysicalMemory, DigitalStorageUnits.Byte)}")
Console.WriteLine($"Available.......: {New Filesize(computerInfo.AvailablePhysicalMemory, DigitalStorageUnits.Byte)}")
Console.WriteLine($"Minimum required: {New Filesize(minMemory, DigitalStorageUnits.Byte)}")
End Sub)
Using lowMemNotify As New LowMemoryNotificationContext(minMemory, action, 1000)
' Allocate all available physical memory:
Dim allocSize As New IntPtr(CLng(computerInfo.AvailablePhysicalMemory))
Dim alloc As IntPtr = Marshal.AllocHGlobal(allocSize)
NativeMethods.ZeroMemory(alloc, allocSize)
' Run job until the low-memory notification occurs.
Do While True
Thread.Sleep(100)
Application.DoEvents()
Loop
End Using
End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
LowMemoryNotificationContext | Initializes a new instance of the LowMemoryNotificationContext class. |
Action | Gets the Action to invoke once if a low-memory notification occurs. |
Minimum | Gets or sets the minimum required memory, in bytes. If the total amount of free physical memory for the computer is lower than this value, the Action specified in Action will be invoked once. |
Dispose | Releases all the resources used by this instance. |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode | Serves as the default hash function. (Inherited from Object) |
GetType | Gets the Type of the current instance. (Inherited from Object) |
ToString | Returns a string that represents the current object. (Inherited from Object) |
CanConvertTo |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
CanConvertToT |
Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions) |
ConvertToT |
Converts an object to the specified target type.
If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions) |
IsDisposable |
Determines whether the specified object is a disposable type
(i.e., it implements IDisposable interface).
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
Speak |
Speaks the string representation of the source object by using the
operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions) |
ThrowIfNullTException |
Throws the specified exception if the source object is null.
(Defined by ObjectExtensions) |