Show / Hide Table of Contents

Class JobObject

Represents a Windows JobObject.

Inheritance
System.Object
JobObjectInfo
JobObject
Implements
System.IDisposable
Inherited Members
JobObjectInfo.GetAccounting()
JobObjectInfo.GetLimits()
JobObjectInfo.GetNotifications()
JobObjectInfo.GetProcessIds()
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Fs.Processes.JobObjects
Assembly: Fs.Processes.dll
Syntax
public sealed class JobObject : JobObjectInfo, IDisposable

Constructors

| Improve this Doc View Source

JobObject(Nullable<JobLimits>, Nullable<JobNotifications>)

Creates a new JobObject instance.

Declaration
public JobObject(JobLimits? Limits = default(JobLimits? ), JobNotifications? Notifications = default(JobNotifications? ))
Parameters
Type Name Description
System.Nullable<JobLimits> Limits

The JobLimits to apply to the new JobObject.

System.Nullable<JobNotifications> Notifications

The JobNotifications to apply to the new JobObject.

Properties

| Improve this Doc View Source

Current

Returns a JobObjectInfo instance for the current process's JobObject, or null if the current process is not associated with a JobObject.

Declaration
public static JobObjectInfo Current { get; }
Property Value
Type Description
JobObjectInfo
| Improve this Doc View Source

Handle

Gets the SafeJobObjectHandle associated with this instance.

Declaration
public SafeJobObjectHandle Handle { get; }
Property Value
Type Description
SafeJobObjectHandle
| Improve this Doc View Source

Idle

Gets a task that completes when the number of active processes decreases to zero.

Declaration
public Task Idle { get; }
Property Value
Type Description
System.Threading.Tasks.Task
| Improve this Doc View Source

SupportsCpuRates

Gets a value indicating whether the OS supports CPU rate limits.

Declaration
public static bool SupportsCpuRates { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

SupportsNotifications

Gets a value indicating whether the OS supports JobNotifications.

Declaration
public static bool SupportsNotifications { get; }
Property Value
Type Description
System.Boolean

Methods

| Improve this Doc View Source

AssignProcess(SafeProcessHandle)

Assigns a process to an existing job object.

Declaration
public void AssignProcess(SafeProcessHandle processHandle)
Parameters
Type Name Description
Microsoft.Win32.SafeHandles.SafeProcessHandle processHandle

A handle to the process to associate with the job object. The handle must have PROCESS_SET_QUOTA and PROCESS_TERMINATE access rights.

| Improve this Doc View Source

AssignProcess(IntPtr)

Assigns a process to an existing job object.

Declaration
public void AssignProcess(IntPtr hProcess)
Parameters
Type Name Description
System.IntPtr hProcess

A handle to the process to associate with the job object. The handle must have PROCESS_SET_QUOTA and PROCESS_TERMINATE access rights.

| Improve this Doc View Source

CreateProcess(CreateProcessInfo)

Creates a new process and assigns the process to the job object.

Declaration
public Process CreateProcess(CreateProcessInfo createProcessInfo)
Parameters
Type Name Description
CreateProcessInfo createProcessInfo

The CreateProcessInfo that contains information this is used to start the process, including the file name and any command-line arguments.

Returns
Type Description
Process

A Process instance that represents the newly created process.

| Improve this Doc View Source

CreateProcess(CreateProcessInfo, ProcessOptions)

Creates a new process and assigns the process to the job object.

Declaration
public Process CreateProcess(CreateProcessInfo createProcessInfo, ProcessOptions processOptions)
Parameters
Type Name Description
CreateProcessInfo createProcessInfo

The CreateProcessInfo that contains information this is used to start the process, including the file name and any command-line arguments.

ProcessOptions processOptions

A set of ProcessOptions that controls how the new process is created.

Returns
Type Description
Process

A Process instance that represents the newly created process.

| Improve this Doc View Source

Dispose()

Releases all resources associated with the instance.

Declaration
public void Dispose()
| Improve this Doc View Source

GrantUserHandleAccess(IntPtr, Boolean)

Grants or denies access to a handle to a User object to a job that has a user-interface restrictions. When access is granted, all processes associated with the job can subsequently recognize and use the handle. When access is denied, the processes can no longer use the handle.

Declaration
public void GrantUserHandleAccess(IntPtr objectHandle, bool allowAccess = true)
Parameters
Type Name Description
System.IntPtr objectHandle

A handle to the User object.

System.Boolean allowAccess

true to grant access to the handle, false to deny access.

| Improve this Doc View Source

GrantUserHandleAccess(SafeHandle, Boolean)

Grants or denies access to a handle to a User object to a job that has a user-interface restrictions. When access is granted, all processes associated with the job can subsequently recognize and use the handle. When access is denied, the processes can no longer use the handle.

Declaration
public void GrantUserHandleAccess(SafeHandle objectHandle, bool allowAccess = true)
Parameters
Type Name Description
System.Runtime.InteropServices.SafeHandle objectHandle

A handle to the User object.

System.Boolean allowAccess

true to grant access to the handle, false to deny access.

| Improve this Doc View Source

Kill(Int32)

Terminate all processes currently associated with the job. If the job is nested, terminate all processes currently associated with the job and all of its child jobs in the hierarchy.

Declaration
public void Kill(int exitCode = -1)
Parameters
Type Name Description
System.Int32 exitCode

The exit code to be used by all processes and threads in the job object.

| Improve this Doc View Source

SetLimits(JobLimits)

Sets the JobObject's limits.

Declaration
public void SetLimits(in JobLimits newLimits)
Parameters
Type Name Description
JobLimits newLimits

The new limits to apply.

| Improve this Doc View Source

SetNotifications(JobNotifications)

Sets the notifications for the JobObject.

Declaration
public void SetNotifications(in JobNotifications newNotifications)
Parameters
Type Name Description
JobNotifications newNotifications

The new notifications to apply.

Events

| Improve this Doc View Source

CpuRateLimitExceeded

Occurs when the CPU rate limit is exceeded.

Declaration
public event EventHandler<RateLimitEventArgs> CpuRateLimitExceeded
Event Type
Type Description
System.EventHandler<RateLimitEventArgs>
| Improve this Doc View Source

Idled

Occurs when all processes assigned to the job have exited.

Declaration
public event EventHandler<EventArgs> Idled
Event Type
Type Description
System.EventHandler<System.EventArgs>
| Improve this Doc View Source

IoLimitExceeded

Occurs when an I/O limit is exceeded.

Declaration
public event EventHandler<IoLimitEventArgs> IoLimitExceeded
Event Type
Type Description
System.EventHandler<IoLimitEventArgs>
| Improve this Doc View Source

MemoryLimitExceeded

Occurs when a process assigned to the job exceeds the per-process memory limit, or when the the job's memory limit is exceeded.

Declaration
public event EventHandler<MemoryLimitEventArgs> MemoryLimitExceeded
Event Type
Type Description
System.EventHandler<MemoryLimitEventArgs>
| Improve this Doc View Source

ProcessAdded

Occurs when a process is assigned to the job.

Declaration
public event EventHandler<ProcessIdEventArgs> ProcessAdded
Event Type
Type Description
System.EventHandler<ProcessIdEventArgs>
| Improve this Doc View Source

ProcessExited

Occurs when a process assigned to the job terminates.

Declaration
public event EventHandler<ProcessExitedEventArgs> ProcessExited
Event Type
Type Description
System.EventHandler<ProcessExitedEventArgs>
| Improve this Doc View Source

ProcessLimitExceeded

Occurs when the active processes limit is exceeded.

Declaration
public event EventHandler<EventArgs> ProcessLimitExceeded
Event Type
Type Description
System.EventHandler<System.EventArgs>
| Improve this Doc View Source

TimeLimitExceeded

Occurs when a process assigned to the job exceeds the per-process time limit, or when the job's time limit is exceeded.

Declaration
public event EventHandler<TimeLimitEventArgs> TimeLimitExceeded
Event Type
Type Description
System.EventHandler<TimeLimitEventArgs>

Implements

System.IDisposable
  • Improve this Doc
  • View Source
Back to top Generated by DocFX