# How to execute the code after submitting the task to Hangfire in .NET Console App

**URL:** <https://discuss.hangfire.io/t/how-to-execute-the-code-after-submitting-the-task-to-hangfire-in-net-console-app/8314>\
**Category:** question\
**Tags:** net40\
**Created:** [March 20, 2021, 4:02am UTC](https://discuss.hangfire.io/t/how-to-execute-the-code-after-submitting-the-task-to-hangfire-in-net-console-app/8314 "2021-03-20T04:02:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![itdev1234](https://avatars.discourse-cdn.com/v4/letter/i/67e7ee/32.png) [@itdev1234](https://discuss.hangfire.io/u/itdev1234)\
**Post date:** [March 20, 2021, 4:02am UTC](https://discuss.hangfire.io/t/how-to-execute-the-code-after-submitting-the-task-to-hangfire-in-net-console-app/8314/1 "2021-03-20T04:02:04Z")

</div>

I have implemented Hangfire in .NET Console Application and It’s working fine. After submitting Tasks(In my case downloading documents) to Hangfire I need to update the status of the Task(Document download status) in the Database, for this, I have the “UpdateDocumentStatus();” method but it never executed (Executing when entering something in the Console cmd window) as I have Console.ReadKey(); in the program. If I remove Console.ReadKey(); Hangfire not working.

Please suggest me alternative to Console.ReadKey(); for Hangfire to execute my “UpdateDocumentStatus();”

```
using System;
using Hangfire;
using Hangfire.MemoryStorage;

namespace HangFire
{
    class Program
    {
        static void Main(string[] args)
        {
            GlobalConfiguration.Configuration.UseMemoryStorage();

            BackgroundJob.Enqueue(() => DownloadDocument());

            using (var server = new BackgroundJobServer())
            {
                Console.ReadKey(); //Need alternative to this line to execute below code
            }

            UpdateDocumentStatus();
        }

        public static void DownloadDocument()
        {
            Console.WriteLine("Downloading documents...");
        }

        public static void UpdateDocumentStatus()
        {
            Console.WriteLine("Update status...");
        }
    }
}
```
