How to successfully run Hangfire MemoryStorage jobs in console application?

Viewed 2358

I'm struggling with starting Hangfire jobs on simple C# console application using MemoryStorage. I wanted to try some things with Hangfire, but I just can't figure out how to configure it.

Here is my code:

    private static void Main(string[] args)
    {
        GlobalConfiguration.Configuration.UseMemoryStorage();

        Hangfire.BackgroundJob.Enqueue(() => Console.WriteLine("fire!"));
        Hangfire.RecurringJob.AddOrUpdate(() => Console.WriteLine("minute!"), Cron.Minutely);

        Console.ReadKey();
    }

I'm not getting any of these messages.

I also tried using JobStorage.Current = new MemoryStorage(new MemoryStorageOptions());, but it didn't change anything.

1 Answers
Related