Finalization
[<Interface>]
type Finalization =
static member Create<'T> (register: Action<'T,Callback<'T>>, registerBeforeExit: Action<'T,Callback<'T>>, unregister: obj -> unit) : Finalization
abstract member register<'T> (ref: 'T, callback: Callback<'T>) : unit
abstract member registerBeforeExit<'T> (ref: 'T, callback: Callback<'T>) : unit
abstract member unregister (ref: obj) : unit| Assembly | Xantham.Fable.Node |
| Attributes | [<Interface>] |
Declared inside
Register | |
RegisterBeforeExit |
Methods
static member Create<'T> (register: Action<'T,Callback<'T>>, registerBeforeExit: Action<'T,Callback<'T>>, unregister: obj -> unit) : Finalizationabstract member register<'T> (ref: 'T, callback: Callback<'T>) : unit
abstract member register<'T> (ref: 'T, callback: Callback<'T>) : unitThis function registers a callback to be called when the process emits the exit event if the ref object was not garbage collected. If the object ref was garbage collected before the exit event is emitted, the callback will be removed from the finalization registry, and it will not be called on process exit.
Inside the callback you can release the resources allocated by the ref object. Be aware that all limitations applied to the beforeExit event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.
The idea of this function is to help you free up resources when the starts process exiting, but also let the object be garbage collected if it is no longer being used.
@since v22.5.0
| Parameter | |
|---|---|
ref | The reference to the resource that is being tracked. |
callback | The callback function to be called when the resource is finalized. |
abstract member registerBeforeExit<'T> (ref: 'T, callback: Callback<'T>) : unit
abstract member registerBeforeExit<'T> (ref: 'T, callback: Callback<'T>) : unitThis function behaves exactly like the register, except that the callback will be called when the process emits the beforeExit event if ref object was not garbage collected.
Be aware that all limitations applied to the beforeExit event are also applied to the callback function, this means that there is a possibility that the callback will not be called under special circumstances.
@since v22.5.0
| Parameter | |
|---|---|
ref | The reference to the resource that is being tracked. |
callback | The callback function to be called when the resource is finalized. |