Share via


IJavaPeerable.DisposeUnlessReferenced Method

Definition

If there are no outstanding references to this instance, then calls Dispose(); otherwise, does nothing.

public void DisposeUnlessReferenced();
abstract member DisposeUnlessReferenced : unit -> unit

Remarks

Call this method when you would like to allow instances to be collectable as soon as possible, but not if the current instance is referenced anywhere else.

<block subset="none" type="note"> "not referenced anywhere else" may mean "is not registered". </block> <block subset="none" type="overrides">

The proscribed implementation template is:

[JniTypeSignature ("my/Example")]
partial class ExampleBinding : IJavaPeerable {

	public void DisposeUnlessReferenced ()
	{
        JniEnvironment.Runtime.ValueManager.DisposeUnlessReferenced (this);
	}
}

</block>

Applies to

See also