Click or drag to resize

JCOBridgeDisposeAsyncScope Class

Opens a batch scope for deferred JVM global reference disposal, safe for use in async/await contexts. Disposal of JVM objects within this scope is batched and flushed in a single P/Invoke call when the scope exits, reducing crossing overhead. The scope state flows automatically across await continuations.
Inheritance Hierarchy
SystemObject
  MASES.JCOBridge.C2JBridgeJCOBridgeDisposeAsyncScope

Namespace: MASES.JCOBridge.C2JBridge
Assembly: C2JBridge (in C2JBridge.dll) Version: 2.6.9.260611-9a148513a79c26cdd7f1dde468f4f9e06ef3bc7e
Syntax
public sealed class JCOBridgeDisposeAsyncScope : IDisposable

The JCOBridgeDisposeAsyncScope type exposes the following members.

Constructors
 NameDescription
Public methodCode exampleJCOBridgeDisposeAsyncScope Initializes a new batch dispose scope for async contexts. Disposal of JVM objects within this scope is batched and flushed in a single native call when the scope exits. The scope state flows automatically across await continuations.
Top
Methods
 NameDescription
Public methodDispose Releases the batch scope, flushing any queued JVM global reference releases in a single native call. Suppresses finalization after disposal.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalize Finalizer
(Overrides ObjectFinalize)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodConvertTReturn Converts a generic object
(Defined by JCOBridgeExtensions)
Public Extension MethodToNative Converts a generic input to an object manageable from the JVM
(Defined by JCOBridgeExtensions)
Top
Remarks
Use this scope when working with async code or when continuations may resume on a different thread. For synchronous hot paths prefer JCOBridgeDisposeFastScope.
Example
C#
await using var scope = new JCOBridgeDisposeAsyncScope();
await foreach (var item in asyncCollection)
{
    using (item) { /* item disposal is batched */ }
}
See Also