IBackgroundJobClientChangeState Method |
Namespace: Hangfire
bool ChangeState( [NotNullAttribute] string jobId, [NotNullAttribute] IState state, [CanBeNullAttribute] string expectedState )
Exception | Condition |
---|---|
ArgumentNullException | jobId is null. |
ArgumentNullException | state is null. |
BackgroundJobClientException | State change failed due to an exception. |
If expectedState value is not null, state change will be performed only if the current state name of a job equal to the given value.
The interface allows implementations to change a state of a background job to other than specified. The given state instance also may be modified. For example, ElectStateContext class contains public setter for the CandidateState property allowing to choose completely different state by state election filters. If a state was changed, value will be returned.