Click or drag to resize
BackgroundJobClient Class
Provides methods for creating all the types of background jobs and changing their states. Represents a default implementation of the IBackgroundJobClient interface.
Inheritance Hierarchy
SystemObject
  HangfireBackgroundJobClient

Namespace: Hangfire
Assembly: Hangfire.Core (in Hangfire.Core.dll) Version: 1.5.0.0
Syntax
public class BackgroundJobClient : IBackgroundJobClient

The BackgroundJobClient type exposes the following members.

Constructors
  NameDescription
Public methodBackgroundJobClient
Initializes a new instance of the BackgroundJobClient class with the storage from a global configuration.
Public methodBackgroundJobClient(JobStorage)
Initializes a new instance of the BackgroundJobClient class with the specified storage.
Public methodBackgroundJobClient(JobStorage, IBackgroundJobFactory, IBackgroundJobStateChanger)
Initializes a new instance of the BackgroundJobClient class with the specified storage, background job factory and state changer.
Top
Methods
  NameDescription
Public methodChangeState
Attempts to change a state of a background job with a given identifier to a specified one.
Public methodCreate
Creates a new background job in a specified state.
Top
Extension Methods
  NameDescription
Public Extension MethodChangeState
Changes state of a job with the given jobId to the specified one.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWith(String, ExpressionAction)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWith(String, ExpressionAction, IState)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWith(String, ExpressionAction, JobContinuationOptions)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWith(String, ExpressionAction, IState, JobContinuationOptions)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWithT(String, ExpressionActionT)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWithT(String, ExpressionActionT, IState)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWithT(String, ExpressionActionT, JobContinuationOptions)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodContinueWithT(String, ExpressionActionT, IState, JobContinuationOptions)Overloaded. (Defined by BackgroundJobClientExtensions.)
Public Extension MethodCreate(ExpressionAction, IState)Overloaded.
Creates a new background job based on a specified static method within a given state.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodCreateT(ExpressionActionT, IState)Overloaded.
Creates a new background job based on a specified instance method within a given state.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodDelete(String)Overloaded.
Changes state of a job with the specified jobId to the DeletedState.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodDelete(String, String)Overloaded.
Changes state of a job with the specified jobId to the DeletedState. If fromState value is not null, state change will be performed only if the current state name of a job equal to the given value.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodEnqueue(ExpressionAction)Overloaded.
Creates a background job based on a specified static method call expression and places it into its actual queue. Please, see the QueueAttribute to learn how to place the job on a non-default queue.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodEnqueueT(ExpressionActionT)Overloaded.
Creates a background job based on a specified instance method call expression and places it into its actual queue. Please, see the QueueAttribute to learn how to place the job on a non-default queue.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodRequeue(String)Overloaded.
Changes state of a job with the specified jobId to the EnqueuedState.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodRequeue(String, String)Overloaded.
Changes state of a job with the specified jobId to the EnqueuedState. If fromState value is not null, state change will be performed only if the current state name of a job equal to the given value.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodSchedule(ExpressionAction, TimeSpan)Overloaded.
Creates a new background job based on a specified static method call expression and schedules it to be enqueued after a given delay.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodSchedule(ExpressionAction, DateTimeOffset)Overloaded.
Creates a new background job based on a specified method call expression and schedules it to be enqueued at the specified moment of time.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodScheduleT(ExpressionActionT, TimeSpan)Overloaded.
Creates a new background job based on a specified instance method call expression and schedules it to be enqueued after a given delay.
(Defined by BackgroundJobClientExtensions.)
Public Extension MethodScheduleT(ExpressionActionT, DateTimeOffset)Overloaded.
Creates a new background job based on a specified method expression and schedules it to be enqueued at the specified moment.
(Defined by BackgroundJobClientExtensions.)
Top
Remarks

This class uses the IBackgroundJobFactory interface for creating background jobs and the IBackgroundJobStateChanger interface for changing their states. Please see documentation for those types and their implementations to learn the details.

Caution note Caution
Despite the fact that instance methods of this class are thread-safe, most implementations of the IState interface are neither thread-safe, nor immutable. Please create a new instance of a state class for each operation to avoid race conditions and unexpected side effects.
Thread Safety
Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.
See Also