fatih
fatih

Reputation: 77

Error #CS0738 'Notification' does not implement interface member 'IJob.Execute(IJobExecutionContext)'. 'Notification.Execute(IJobExecutionContext)'

using System;
using Quartz;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hatirlaticiapp
{
    public class Notification : IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            JobDataMap data = context.JobDetail.JobDataMap;
            Task task = (Task)data["Task"];
            task.OnNotificationStarted(task, EventArgs.Empty);
        }
    }
}

For this line of code I am getting such a warning.

ERROR :

Error CS0738 'Notification' does not implement interface member 'IJob.Execute(IJobExecutionContext)'. 'Notification.Execute(IJobExecutionContext)' cannot implement 'IJob.Execute(IJobExecutionContext)' because it does not have the matching return type of 'Task'.

EDIT 1 : add my scheduling code

public class NotificationController : IController<Task>
{
    ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
    IScheduler scheduler;

    public NotificationController()
    {            
        scheduler = schedulerFactory.GetScheduler();
        scheduler.Start();
    }
}

I am getting this error here too

ERROR : Cannot implicitly convert type 'System.Threading.Tasks.Task<Quartz.IScheduler>' to 'Quartz.IScheduler'. An explicit conversion exists (are you missing a cast?)

Please help me ...

Upvotes: 0

Views: 1944

Answers (2)

sgmoore
sgmoore

Reputation: 16067

It might be beneficial to look at https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/index.html as it looks like some of your code is written for Version 2.2 but the error messages would suggest you are using Version 3.

In particular your second error may be because you are missing awaits, ie

  scheduler = schedulerFactory.GetScheduler();
  scheduler.Start();

should be

  scheduler = await schedulerFactory.GetScheduler();
  await scheduler.Start();

Also your first signature should be

  public async Task Execute(IJobExecutionContext context)

and presumably you need to use await in the actual code.

Upvotes: 2

ΩmegaMan
ΩmegaMan

Reputation: 31616

Read the whole exception, at the end it says

... because it does not have the matching return type of 'Task'.

Change the return from void to Task.

Upvotes: 0

Related Questions