Java.Nio.Channels.FileChannel.TryLock Method
Attempts to acquire an exclusive lock on this file without blocking.

Syntax

[Android.Runtime.Register("tryLock", "(JJZ)Ljava/nio/channels/FileLock;", "GetTryLock_JJZHandler")]
public abstract FileLock TryLock (long position, long size, bool shared)

Parameters

position
the starting position.
size
the size of file to lock.
shared
true if the lock is shared.

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Java.Lang.IllegalArgumentExceptionif any parameters are invalid.
Java.Nio.Channels.ClosedChannelExceptionif the file channel is closed.
Java.Nio.Channels.OverlappingFileLockExceptionif a lock is already held that overlaps this lock request or another thread is waiting to acquire a lock that will overlap with this request.
Java.IO.IOExceptionif any I/O error occurs.

Remarks

Attempts to acquire an exclusive lock on this file without blocking. The method returns null if the acquisition would result in an overlapped lock with another OS process.

It is possible to acquire a lock for any region even if it's completely outside of the file's size. The size of the lock is fixed. If the file grows outside of the lock that region of the file won't be locked by this lock.

[Android Documentation]

Requirements

Namespace: Java.Nio.Channels
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1