I have scheduled a Job via using Hangfire library. My scheduled Code like below.
BackgroundJob.Schedule(() => MyRepository.SomeMethod(2),TimeSpan.FromDays(7));
public static bool DownGradeUserPlan(int userId)
{
//Write logic here
}
Now I want to Delete this Scheduled Job later on some event.
BackgroundJob.Schedule
returns you an id of that job, you can use it to delete this job:
var jobId = BackgroundJob.Schedule(() => MyRepository.SomeMethod(2),TimeSpan.FromDays(7));
BackgroundJob.Delete(jobId);