Job2 Class

Definition

New base class for a job that provides extended state management functionality on the job. Since the existing Job class is an abstract class and there are existing implementations of the same, it is required to have a new class that will have the extended functionality. This is to ensure that backwards compatibility is maintained

        However, this class will derive from the existing Job
        class. The option of deprecating the existing class was
        considered as well. In order to maintain backwards
        compatibility of PowerShell job cmdlets they will have
        to work with the old interface and hence deprecating
        the Job class did not add any benefit rather than
        deriving from the same
public abstract class Job2 : System.Management.Automation.Job
Inheritance
Job2
Derived

Inherited Members

System.Management.Automation.Job

Remarks

The following are some of the notes about why the asynchronous operations are provided this way in this class. There are two possible options in which asynchornous support can be provided:

  1. Classical pattern (Begin and End)
  2. Event based pattern

    Although the PowerShell API uses the classical pattern and we would like the Job API and PowerShell API to be as close as possible, the classical pattern is inherently complex to use.

Constructors

Job2()

Default no argument constructor

Job2(String)

Constructor which will initialize the job with the associated command string

Job2(String, String)

Creates an instance of this class

Job2(String, String, IList<Job>)

Creates an instance of this class

Job2(String, String, Guid)

Creates an instance of this class

Job2(String, String, JobIdentifier)

Creates an instance of this class

Properties

StartParameters

Parameters to be used to start a job. This is a property because CommandParameterCollection does not have a public constructor. Hence the infrastructure creates an instance and provides it for the implementations to use

SyncRoot

Methods

OnResumeJobCompleted(AsyncCompletedEventArgs)

Method which can be extended or called by derived classes to raise the event when resuming a suspended job is completed

OnStartJobCompleted(AsyncCompletedEventArgs)

Method which can be extended or called by derived classes to raise the event when start of the job is completed

OnStopJobCompleted(AsyncCompletedEventArgs)

Method which can be extended or called by derived classes to raise the event when stopping a job is completed

OnSuspendJobCompleted(AsyncCompletedEventArgs)

Method which can be exteded or called by derived classes to raise the event when suspending a job is completed

OnUnblockJobCompleted(AsyncCompletedEventArgs)

Method which can be extended or called by derived classes to raise the event when unblocking a blocked job is completed

ResumeJob()

Resume a suspended job

ResumeJobAsync()

Resume a suspended job asynchronously.

SetJobState(JobState, Exception)

There is an internal method in Job which is not made public. In order to make this available to someone implementing a job it has to be added here. If the original method is made public it has changes of colliding with some implementation which may have added that method

StartJob()

start a job. The job will be started with the parameters specified in StartParameters

StartJobAsync()

Start a job asynchronously

StopJob(Boolean, String)

StopJob

StopJobAsync()

Stop a job asynchronously

StopJobAsync(Boolean, String)

StopJobAsync

SuspendJob()

Suspend a job

SuspendJob(Boolean, String)

SuspendJob

SuspendJobAsync()

Asynchronously suspend a job

SuspendJobAsync(Boolean, String)

SuspendJobAsync

UnblockJob()

Unblock a blocked job

UnblockJobAsync()

Unblock a blocked job asynchronously

Events

ResumeJobCompleted

This event should be raised whenever the asynchronous resume of a suspended job is completed. This event should not be raised for synchronous operation

StartJobCompleted

Event to be raise when the start job activity is completed. This event should not be raised for synchronous operation

StopJobCompleted

Event to be raised when the asynchronous stopping of a job is completed.This event should not be raised for synchronous operation

SuspendJobCompleted

This event should be raised whenever the asynchronous suspend of a job is completed. This event should not be raised for synchronous operation

UnblockJobCompleted

This event should be raised whenever the asynchronous unblock of a blocked job is completed. This event should not be raised for synchronous operation