I have a console application for testing HangFire. Here is the code:
using System; using Hangfire; namespace MyScheduler.ConsoleApp { internal static class Program { internal static void Main(string[] args) { MyMethod(); Console.WriteLine("[Finished]"); Console.ReadKey(); } private static void MyMethod() { RecurringJob.AddOrUpdate(() => Console.Write("Easy!"), Cron.Minutely); } } }
But it throws an exception at runtime:
Additional Information: The value of the JobStorage.Current property was not initialized. You must install it before using the Hangfire Client or Server API.
To do this, I need a job repository. But all the examples are in SQL repository, etc. Is there any way to run this example with some kind of memory store?
JobStorage.Current = new SqlServerStorage("ConnectionStringName", options); // to JobStorage.Current = new MemoryDbStorage(string.Empty, options);
source share