How to use Hangfire with asp.net hosted service?

recurring
Tags: #<Tag:0x00007f499ac3fd58>

#1

I have a simple HostedService. I need to run some tasks by time. How can I use Hangfire in Memory if I don’t have WebHost?

My Program.cs
public static Task Main()
{
var hostBuilder = new HostBuilder()
.ConfigureAppConfiguration((hostContext, config) =>
{
config
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(“appsettings.json”, optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
})
.ConfigureServices((hostContext, services) =>
{
services
.AddCoreIntegrations();

			services.AddHostedService<Application>();
		});
	
	return hostBuilder.RunConsoleAsync();
}

How to configure Handfire and where I can run
RecurringJob.AddOrUpdate(() = Console.WriteLine("Transparent!"), Cron.Daily);