Compartilhar via


Process.WaitFor Method

Definition

Overloads

WaitFor()

Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated.

WaitFor(Int64, TimeUnit)

Causes the current thread to wait, if necessary, until the subprocess represented by this Process object has terminated, or the specified waiting time elapses.

WaitFor()

Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated.

[Android.Runtime.Register("waitFor", "()I", "GetWaitForHandler")]
public abstract int WaitFor ();
[<Android.Runtime.Register("waitFor", "()I", "GetWaitForHandler")>]
abstract member WaitFor : unit -> int

Returns

the exit value of the subprocess represented by this Process object. By convention, the value 0 indicates normal termination.

Attributes

Exceptions

if the calling thread is interrupted.

Remarks

Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated. This method returns immediately if the subprocess has already terminated. If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits.

Java documentation for java.lang.Process.waitFor().

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

WaitFor(Int64, TimeUnit)

Causes the current thread to wait, if necessary, until the subprocess represented by this Process object has terminated, or the specified waiting time elapses.

[Android.Runtime.Register("waitFor", "(JLjava/util/concurrent/TimeUnit;)Z", "GetWaitFor_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=26)]
public virtual bool WaitFor (long timeout, Java.Util.Concurrent.TimeUnit? unit);
[<Android.Runtime.Register("waitFor", "(JLjava/util/concurrent/TimeUnit;)Z", "GetWaitFor_JLjava_util_concurrent_TimeUnit_Handler", ApiSince=26)>]
abstract member WaitFor : int64 * Java.Util.Concurrent.TimeUnit -> bool
override this.WaitFor : int64 * Java.Util.Concurrent.TimeUnit -> bool

Parameters

timeout
Int64

the maximum time to wait

unit
TimeUnit

the time unit of the timeout argument

Returns

true if the subprocess has exited and false if the waiting time elapsed before the subprocess has exited.

Attributes

Remarks

Causes the current thread to wait, if necessary, until the subprocess represented by this Process object has terminated, or the specified waiting time elapses.

If the subprocess has already terminated then this method returns immediately with the value true. If the process has not terminated and the timeout value is less than, or equal to, zero, then this method returns immediately with the value false.

The default implementation of this methods polls the exitValue to check if the process has terminated. Concrete implementations of this class are strongly encouraged to override this method with a more efficient implementation.

Added in 1.8.

Java documentation for java.lang.Process.waitFor(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