2016-02-27 29 views
4

我使用FluentScheduler,并有登记类,如何停止FluentScheduler的任务?

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

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

和应用程序,我将其初始化。

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

它运行每5分。

我想停止这个。我该如何阻止此调度程序?

回答

5

我为计划设置了一个名称。

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

和停止它,使用RemoveTask

TaskManager.RemoveTask("UnreadAlertRegistry");