Click or drag to resize
BackgroundJobClientExtensionsDelete Method (IBackgroundJobClient, String, String)
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.

Namespace: Hangfire
Assembly: Hangfire.Core (in Hangfire.Core.dll) Version: 1.5.0.0
Syntax
public static bool Delete(
	[NotNullAttribute] this IBackgroundJobClient client,
	[NotNullAttribute] string jobId,
	[CanBeNullAttribute] string fromState
)

Parameters

client
Type: HangfireIBackgroundJobClient
An instance of IBackgroundJobClient implementation.
jobId
Type: SystemString
Identifier of job, whose state is being changed.
fromState
Type: SystemString
Current state assertion, or null if unneeded.

Return Value

Type: Boolean
True, if state change succeeded, otherwise false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IBackgroundJobClient. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
The job is not actually being deleted, this method changes only its state. This operation does not provides guarantee that the job will not be performed. If you deleting a job that is performing right now, it will be performed anyway, despite of this call. The method returns result of a state transition. It can be false if a job was expired, its method does not exist or there was an exception during the state change process.
See Also