Click or drag to resize
DeletedState Class
Defines the final state of a background job when nobody is interested whether it was performed or not.
Inheritance Hierarchy
SystemObject
  Hangfire.StatesDeletedState

Namespace: Hangfire.States
Assembly: Hangfire.Core (in Hangfire.Core.dll) Version: 1.5.0.0
Syntax
public class DeletedState : IState

The DeletedState type exposes the following members.

Constructors
  NameDescription
Public methodDeletedState
Initializes a new instance of the DeletedState class.
Top
Properties
  NameDescription
Public propertyDeletedAt
Gets a date/time when the current state instance was created.
Public propertyIgnoreJobLoadException
Gets whether transition to this state should ignore job de-serialization exceptions.
Public propertyIsFinal
Gets if the current state is a final one.
Public propertyName
Gets the unique name of the state.
Public propertyReason
Gets the human-readable reason of a state transition.
Top
Methods
  NameDescription
Public methodSerializeData
Gets a serialized representation of the current state.
Top
Fields
  NameDescription
Public fieldStatic memberStateName
Represents the name of the Deleted state. This field is read-only.
Top
Remarks

Deleted state is used when you are not interested in a processing of a background job. This state isn't backed by any background process, so when you change a state of the job to the Deleted, only expiration time will be set on a job without any additional processing.

Examples

The following example demonstrates how to cancel an enqueued background job. Please note that this job may be processed before you change its state.

This example shows how to create an instance of the DeletedState class and use the ChangeState(String, IState, String) method. Please see BackgroundJob.Delete and BackgroundJobClientExtensions.Delete method overloads for simpler API.

C#
var client = new BackgroundJobClient();
var jobId = client.Enqueue(() => Console.WriteLine("Hello"));

var state = new DeletedState();
client.ChangeState(jobId, state, EnqueuedState.StateName);
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also