# Keep watching JobId state

**URL:** <https://discuss.hangfire.io/t/keep-watching-jobid-state/1420>\
**Category:** question\
**Created:** [October 14, 2015, 10:40am UTC](https://discuss.hangfire.io/t/keep-watching-jobid-state/1420 "2015-10-14T10:40:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingjayakumarv](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@kingjayakumarv](https://discuss.hangfire.io/u/kingjayakumarv)\
**Post date:** [October 14, 2015, 10:40am UTC](https://discuss.hangfire.io/t/keep-watching-jobid-state/1420/1 "2015-10-14T10:40:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yngndrw](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/yngndrw/32/83_2.png) [@yngndrw](https://discuss.hangfire.io/u/yngndrw)\
**Post date:** [October 14, 2015, 12:39pm UTC](https://discuss.hangfire.io/t/keep-watching-jobid-state/1420/2 "2015-10-14T12:39:23Z")

</div>

The [`GetStateData` method on `IStorageConnection`](https://github.com/HangfireIO/Hangfire/blob/5d7a1bddb10cc48d5fef248344871931ab686e35/src/Hangfire.Core/Storage/IStorageConnection.cs#L46) should get you the data you need:

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

```
