2016-02-27 149 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");