Udostępnij za pośrednictwem


ITransferQueue.TryTransfer Method

Definition

Overloads

TryTransfer(Object)

Transfers the element to a waiting consumer immediately, if possible.

TryTransfer(Object, Int64, TimeUnit)

Transfers the element to a consumer if it is possible to do so before the timeout elapses.

TryTransfer(Object)

Transfers the element to a waiting consumer immediately, if possible.

[Android.Runtime.Register("tryTransfer", "(Ljava/lang/Object;)Z", "GetTryTransfer_Ljava_lang_Object_Handler:Java.Util.Concurrent.ITransferQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public bool TryTransfer (Java.Lang.Object? e);
[<Android.Runtime.Register("tryTransfer", "(Ljava/lang/Object;)Z", "GetTryTransfer_Ljava_lang_Object_Handler:Java.Util.Concurrent.ITransferQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member TryTransfer : Java.Lang.Object -> bool

Parameters

e
Object

the element to transfer

Returns

true if the element was transferred, else false

Attributes

Remarks

Transfers the element to a waiting consumer immediately, if possible.

More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in #take or timed #poll(long,TimeUnit) poll), otherwise returning false without enqueuing the element.

Java documentation for java.util.concurrent.TransferQueue.tryTransfer(E).

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

TryTransfer(Object, Int64, TimeUnit)

Transfers the element to a consumer if it is possible to do so before the timeout elapses.

[Android.Runtime.Register("tryTransfer", "(Ljava/lang/Object;JLjava/util/concurrent/TimeUnit;)Z", "GetTryTransfer_Ljava_lang_Object_JLjava_util_concurrent_TimeUnit_Handler:Java.Util.Concurrent.ITransferQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public bool TryTransfer (Java.Lang.Object? e, long timeout, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("tryTransfer", "(Ljava/lang/Object;JLjava/util/concurrent/TimeUnit;)Z", "GetTryTransfer_Ljava_lang_Object_JLjava_util_concurrent_TimeUnit_Handler:Java.Util.Concurrent.ITransferQueueInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member TryTransfer : Java.Lang.Object * int64 * Java.Util.Concurrent.TimeUnit -> bool

Parameters

e
Object

the element to transfer

timeout
Int64

how long to wait before giving up, in units of unit

unit
TimeUnit

a TimeUnit determining how to interpret the timeout parameter

Returns

true if successful, or false if the specified waiting time elapses before completion, in which case the element is not left enqueued

Attributes

Remarks

Transfers the element to a consumer if it is possible to do so before the timeout elapses.

More precisely, transfers the specified element immediately if there exists a consumer already waiting to receive it (in #take or timed #poll(long,TimeUnit) poll), else waits until the element is received by a consumer, returning false if the specified wait time elapses before the element can be transferred.

Java documentation for java.util.concurrent.TransferQueue.tryTransfer(E, long, java.util.concurrent.TimeUnit).

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