# Best practices or guidelines for code being setup for Hangfire jobs

**URL:** <https://discuss.hangfire.io/t/best-practices-or-guidelines-for-code-being-setup-for-hangfire-jobs/1209>\
**Category:** question\
**Created:** [August 9, 2015, 11:41am UTC](https://discuss.hangfire.io/t/best-practices-or-guidelines-for-code-being-setup-for-hangfire-jobs/1209 "2015-08-09T11:41:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjm](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/hjm/32/326_2.png) [@hjm](https://discuss.hangfire.io/u/hjm)\
**Post date:** [August 9, 2015, 11:41am UTC](https://discuss.hangfire.io/t/best-practices-or-guidelines-for-code-being-setup-for-hangfire-jobs/1209/1 "2015-08-09T11:41:16Z")

</div>

Are there any best practices around code being queued? Lets say if I have a method like this crashing, would the worker handle the crash and re-queue the job?

```
public void EnqueuedMethod(int someId)
{
   //no exception handling here
}

```

If its hangfire scheduled method is internally calling a method which is async, should I configure the awaitable to false?

```
    private async Task<NotificationOutcome> Send(string json, string[] tags)
    {
        return await Hubclient.SendNativeNotificationAsync(json, tags)
                              .ConfigureAwait(false);
    }

```

I’m looking for some guidelines, we are experiencing once in a while Hangfire worker lockups and I do think it is due to our code not being setup correctly to run inside the hangfire process.

Another topic is we have an EF datacontect which is thread scoped/instantiated. Would this be a wise thing to run inside a enqued method? Or since the workers are running forever, would this mean this datacontext is created once per thread and lives forever?
