Hangfire Unity full example

Hi, I’m trying to find a working example of Hangfire with Unity (or any other IoC for that matter)
I couldn’t get it to work and my search yielded lots of people having issues with IoC setup but no real answers.
could someone please point me to a working sample app… please…

So I don’t have a snippet I can share easily with my working Unity setup. But what part it “not working” for you? Are you able to successfully use Unity in other ways within your applications? Or is it specifically an issue with Hangfire?

The basics are:

  1. configure your Container. (container.RegisterType<IThing,Thing>())

  2. tell hangfire to use the container:

    GlobalConfiguration.Configuration.UseUnityActivator(container);

  3. then enqueue your jobs

    BackgroundJob.Enqueue(thing=>thing.Method(parameters))

1 Like