My aim was to configure the Hangfire in a central Api assembly so that I dont have to add the hangfire to all other assemblies. I am posting my solution here for others who need to do something similar
Blow is the interface and the class I added in the Api assembly
''' <summary>
''' Interface should be implemented by a class if it wants to run
''' </summary>
''' <remarks></remarks>
Public Interface IJob
Sub DoJob()
End Interface
Public Class Scheduler
''' <summary>
''' Adds a background job to be executed.
''' </summary>
''' <typeparam name="T"></typeparam>
''' <param name="sJob"></param>
''' <remarks></remarks>
Public Shared Sub AddBackgroundJob(Of T)()
BackgroundJob.Enqueue(Of T)(Sub(job) CType(job, IJob).DoJob())
End Sub
End Class
Then in one of the other assemblies I did this to add jobs to Hangfire, currently it just contains a method to add a Fire and Forget job.
Class StatScheduler
Implements IJob
Public Sub DoJob() Implements IJob.DoJob
' ToDo
End Sub
End Class
Then finally we send job to the Api form the target assembly like this
Scheduler.AddBackgroundJob(Of StatScheduler)()