Click or drag to resize
EnqueuedState Class
Defines the intermediate state of a background job when it is placed on a message queue to be processed by the Worker background process as soon as possible.
Inheritance Hierarchy
SystemObject
  Hangfire.StatesEnqueuedState

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

The EnqueuedState type exposes the following members.

Constructors
  NameDescription
Public methodEnqueuedState
Initializes a new instance of the EnqueuedState class with the default queue name.
Public methodEnqueuedState(String)
Initializes a new instance of the EnqueuedState class with the specified queue name.
Top
Properties
  NameDescription
Public propertyEnqueuedAt
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 propertyQueue
Gets or sets a queue name to which a background job identifier will be added.
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 memberDefaultQueue
Represents the default queue name. This field is constant.
Public fieldStatic memberStateName
Represents the name of the Enqueued state. This field is read-only.
Top
Remarks

Background job in EnqueuedState is referred as fire-and-forget job.

Background job identifier is placed on a queue with the given name. When a queue name wasn't specified, the DefaultQueue name will be used. Message queue implementation depends on a current JobStorage instance.

Examples
The following example demonstrates the creation of a background job in EnqueuedState. Please see BackgroundJob.Enqueue and BackgroundJobClientExtensions.Enqueue method overloads for simpler API.
var client = new BackgroundJobClient();
var state = new EnqueuedState("critical"); // Use the "critical" queue

client.Create(() => Console.WriteLine("Hello!"), state);
The code below implements the retry action for a failed background job.
var client = new BackgroundJobClient();
var state = new EnqueuedState(); // Use the default queue

client.ChangeState(jobId, state, FailedState.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