DeletedState Class |
Namespace: Hangfire.States
The DeletedState type exposes the following members.
Name | Description | |
---|---|---|
DeletedState |
Initializes a new instance of the DeletedState class.
|
Name | Description | |
---|---|---|
DeletedAt |
Gets a date/time when the current state instance was created.
| |
IgnoreJobLoadException |
Gets whether transition to this state should ignore job de-serialization
exceptions.
| |
IsFinal |
Gets if the current state is a final one.
| |
Name |
Gets the unique name of the state.
| |
Reason |
Gets the human-readable reason of a state transition.
|
Name | Description | |
---|---|---|
SerializeData |
Gets a serialized representation of the current state.
|
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.
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.
var client = new BackgroundJobClient(); var jobId = client.Enqueue(() => Console.WriteLine("Hello")); var state = new DeletedState(); client.ChangeState(jobId, state, EnqueuedState.StateName);