Instance Method


Block until the receiver is finished.


func waitUntilExit()


This method first checks to see if the receiver is still running using isRunning. Then it polls the current run loop using NSDefaultRunLoopMode until the task completes.

let task: NSTask = // Create and initialize a task
let status = task.terminationStatus
if status == 0 {
    print("Task succeeded.")
} else {
    print("Task failed.")

waitUntilExit() does not guarantee that the terminationHandler block has been fully executed before waitUntilExit() returns.

See Also

Running and Stopping a Task

func interrupt()

Sends an interrupt signal to the receiver and all of its subtasks.

func launch()

Launches the task represented by the receiver.

func resume() -> Bool

Resumes execution of the receiver task that had previously been suspended with a suspend() message.

func suspend() -> Bool

Suspends execution of the receiver task.

func terminate()

Sends a terminate signal to the receiver and all of its subtasks.