Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a task of FluentScheduler?

I am using FluentScheduler, and have a Registry class,

public class UnreadAlertRegistry : Registry
{
  public UnreadAlertRegistry(int minute, string user, bool? type)
    {

        var alertAction = new Action(() =>
          {
            // show message box 
          }
       Schedule(alertAction).ToRunEvery(minute).Minutes();
     }
  }

and in app, i Initialize it.

alert = new UnreadAlertRegistry(5, _dashboardUser, false);
TaskManager.Initialize(alert);

it is run every 5 minute.

I want to stop this. How do i stop this Scheduler?

like image 634
ar.gorgin Avatar asked Feb 27 '16 10:02

ar.gorgin


1 Answers

I set a Name for schedule.

Schedule(alertAction).WithName("UnreadAlertRegistry").ToRunEvery(minute).Minutes();

and for stop it , use RemoveTask

TaskManager.RemoveTask("UnreadAlertRegistry");
like image 149
ar.gorgin Avatar answered Sep 27 '22 21:09

ar.gorgin