Platforms to show: All Mac Windows Linux Cross-Platform
NSTaskMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Cocoa Tasks | MBS MacCocoa Plugin | 9.7 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
An NSTask object creates a separate executable entity; it differs from NSThread in that it does not share memory space with the process that creates it.
A task operates within an environment defined by the current values for several items: the current directory, standard input, standard output, standard error, and the values of any environment variables. By default, an NSTask object inherits its environment from the process that launches it. If there are any values that should be different for the task, for example, if the current directory should change, you must change the value before you launch the task. A task's environment cannot be changed while it is running.
An NSTask object can only be run once. Subsequent attempts to run the task raise an error.
This class is comparable to the shell classe built into Xojo.
See also WindowsProcessMBS and WindowsShellExecuteMBS (Windows only), ConsoleExecuteMBS and ShellMBS (cross platform).
- event Terminated
- 9 properties
- property currentDirectoryPath as string
- property Handle as Integer
- property isRunning as boolean
- property launchPath as string
- property processIdentifier as Integer
- property qualityOfService as Integer
- property terminationReason as Integer
- property terminationStatus as Integer
- property environment as dictionary
- 19 methods
- method arguments as string()
- method Constructor
- method Destructor
- method interrupt
- method launch
- method resume as boolean
- method setArguments(arguments() as string)
- method setStandardError(p as NSFileHandleMBS)
- method setStandardError(p as NSPipeMBS)
- method setStandardInput(p as NSFileHandleMBS)
- method setStandardInput(p as NSPipeMBS)
- method setStandardOutput(p as NSFileHandleMBS)
- method setStandardOutput(p as NSPipeMBS)
- method standardError as Variant
- method standardInput as Variant
- method standardOutput as Variant
- method suspend as boolean
- method terminate
- method waitUntilExit
- 2 shared methods
- shared method launchedTaskWithLaunchPath(path as string, arguments() as string) as NSTaskMBS
- shared method NSTaskDidTerminateNotification as string
- 7 constants
Constants
Constant | Value | Description |
---|---|---|
NSTaskTerminationReasonExit | 1 |
One of the constants used to specify the values that are returned by terminationReason.
The task exited normally. |
NSTaskTerminationReasonUncaughtSignal | 2 |
One of the constants used to specify the values that are returned by terminationReason.
The task exited due to an uncaught signal. |
Quality of Service Constants
Constant | Value | Description |
---|---|---|
NSQualityOfServiceBackground | &h09 |
Background QoS is used for work that is not user initiated or visible. In general, a user is unaware that this work is even happening and it will run in the most efficient manner while giving the most deference to higher QoS work. For example, pre-fetching content, search indexing, backups, and syncing of data with external systems. |
NSQualityOfServiceDefault | -1 |
Default QoS indicates the absence of QoS information. Whenever possible QoS information will be inferred from other sources. If such inference is not possible, a QoS between UserInitiated and Utility will be used. |
NSQualityOfServiceUserInitiated | &h19 |
UserInitiated QoS is used for performing work that has been explicitly requested by the user and for which results must be immediately presented in order to allow for further user interaction. For example, loading an email after a user has selected it in a message list. |
NSQualityOfServiceUserInteractive | &h21 |
UserInteractive QoS is used for work directly involved in providing an interactive UI such as processing events or drawing to the screen. |
NSQualityOfServiceUtility | &h11 |
Utility QoS is used for performing work which the user is unlikely to be immediately waiting for the results. This work may have been requested by the user or initiated automatically, does not prevent the user from further interaction, often operates at user-visible timescales and may have its progress indicated to the user by a non-modal progress indicator. This work will run in an energy-efficient manner, in deference to higher QoS work when resources are constrained. For example, periodic content updates or bulk file operations such as media import. |
This class has no sub classes.
Some examples using this class:
- /MacCocoa/NSTask/NSTask
- /MacCocoa/NSTask/NSTask live output
- /MacCocoa/NSTask/NSTask traceroute
- /MacCocoa/NSTask/NSTask with Arguments
- /MacCocoa/readToEndOfFileInBackgroundAndNotify Test
Blog Entries
The items on this page are in the following plugins: MBS MacCocoa Plugin.
NSTabViewMBS - NSTextAttachmentMBS