Running Task() that is stored in an object within a ReoccurringJob


#1

Hi,

Within my application, I have created an Event object that includes an ID and a Task that needs to be run in this event as follows:-

public class Event
{
    public int Id { get; set; }
    // Other Variables Here
    public Task Action { get; set; }
}

In order for my application to work, I need to create a ReoccurringJob that gets the required Event based off the Id and runs the Action variable from this event. The code I currently have, and am having issues with is as follows:-

Event evnt = eventRepository.GetEvent(id);
RecurringJob.AddOrUpdate(evnt.Name, () => evnt.Action.Start(), Cron.MinuteInterval(int.Parse(evnt.Timing)));   

However, I am getting the issue

No parameterless constructor defined for this object.

when viewing this on the DashBoard. Can anyone help me find a way to run this task?

Any help is greatly appreciated