type of StdSchedulerFactory.GetDefaultScheduler() is task not IScheduler,so I got following error.
how can I fix this?
type of StdSchedulerFactory.GetDefaultScheduler() is task not IScheduler,so I got following error.
how can I fix this?
You have to await
for the result. I suppose you are not awaiting.
StdSchedulerFactory factory = new StdSchedulerFactory(props);
IScheduler scheduler = await factory.GetScheduler();
await scheduler.Start();
Here is complete example from Quartz docs.
private static async Task RunProgram()
{
try
{
// Grab the Scheduler instance from the Factory
NameValueCollection props = new NameValueCollection
{
{ "quartz.serializer.type", "binary" }
};
StdSchedulerFactory factory = new StdSchedulerFactory(props);
IScheduler scheduler = await factory.GetScheduler();
// and start it off
await scheduler.Start();
// some sleep to show what's happening
await Task.Delay(TimeSpan.FromSeconds(60));
// and last shut down the scheduler when you are ready to close your program
await scheduler.Shutdown();
}
catch (SchedulerException se)
{
await Console.Error.WriteLineAsync(se.ToString());
}
}