Keep watching JobId state

Hi All,

Am using hangfire to run background works, like below.
In my business layer calling Data access layer to get some data(Long running) then do some business calculation and update into backend.
This block of process code i moved into hangfire section
var tempJobId = BackgroundJob.Enqueue(() => hngFire.HangFireStartNewJob(JobCancellationToken.Null));

Here i got what i needed, my sceario is when i called BackgroundJob.Enqueue() i got job id for specific request, then program control move to next line for further.
I want to keeo track request task(JobId) like if it Started, Processing, Cancelled, Failed, Success, etc.
Note: Auto code management, when i run application in mapped DB.[HangFire].[State] table been updating status for every Job.

How i get JobId status in my code?

Thanks,
jai

The GetStateData method on IStorageConnection should get you the data you need:

using (IStorageConnection storageConnection = JobStorage.Current.GetConnection())
{
    string jobID = ...
    StateData stateData = storageConnection.GetStateData(jobID);
    string stateName = stateData.Name;
}