0
我試圖兩次提醒在Windows Phone應用程序添加到ScheduledActionService
如下:增加兩個提醒ScheduledActionService在Windows Phone的
private void button1_Click(object sender, RoutedEventArgs e)
{
if (ScheduledActionService.Find("PomodoroAkshay") != null)
{
ScheduledActionService.Remove("PomodoroAkshay");
this.Storyboard_Copy1.Begin();
this.textBlock1.Text = "It's stopped!";
if (ScheduledActionService.Find("BreakAkshay") != null)
{
ScheduledActionService.Remove("BreakAkshay");
}
}
else
{
if (ScheduledActionService.Find("BreakAkshay") != null)
{
ScheduledActionService.Remove("BreakAkshay");
}
Reminder brk = new Reminder("BreakAkshay");
brk.Title = "BreakUP";
brk.Content = "Time up!";
brk.BeginTime = DateTime.Now.AddSeconds(20);
ScheduledActionService.Add(brk);
Reminder pdro = new Reminder("PomodoroAkshay");
pdro.Title = "PomodoroUP";
pdro.Content = "Time for break!";
pdro.BeginTime = DateTime.Now.AddSeconds(5);
ScheduledActionService.Add(pdro);
this.Storyboard1.Begin();
this.textBlock1.Text = "It's running!";
}
}
當我按下button1
上改弦更張,else
被如預期觸發。但是,我收到三封提醒。其中兩個(PomodoroAkshay
和BreakAkshay
)五秒鐘後觸發。另外,如預期的那樣,在20秒後觸發BreakAkshay
。不過,我想要的只是在5秒後觸發一次提醒,在20秒後觸發第二次提醒。我哪裏錯了?
附加信息:該語句if
清除提醒,以便button1
充當切換按鈕。