Compartilhar via


IBaseStream.OnClose(IRunnable) Method

Definition

Returns an equivalent stream with an additional close handler.

[Android.Runtime.Register("onClose", "(Ljava/lang/Runnable;)Ljava/util/stream/BaseStream;", "GetOnClose_Ljava_lang_Runnable_Handler:Java.Util.Streams.IBaseStreamInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=24)]
public Java.Lang.Object? OnClose (Java.Lang.IRunnable? closeHandler);
[<Android.Runtime.Register("onClose", "(Ljava/lang/Runnable;)Ljava/util/stream/BaseStream;", "GetOnClose_Ljava_lang_Runnable_Handler:Java.Util.Streams.IBaseStreamInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=24)>]
abstract member OnClose : Java.Lang.IRunnable -> Java.Lang.Object

Parameters

closeHandler
IRunnable

A task to execute when the stream is closed

Returns

a stream with a handler that is run if the stream is closed

Attributes

Remarks

Returns an equivalent stream with an additional close handler. Close handlers are run when the #close() method is called on the stream, and are executed in the order they were added. All close handlers are run, even if earlier close handlers throw exceptions. If any close handler throws an exception, the first exception thrown will be relayed to the caller of close(), with any remaining exceptions added to that exception as suppressed exceptions (unless one of the remaining exceptions is the same exception as the first exception, since an exception cannot suppress itself.) May return itself.

This is an intermediate operation.

Java documentation for java.util.stream.BaseStream.onClose(java.lang.Runnable).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to