2013-03-18 68 views
0

我正在寫一個應用程序(Windows Phone 8),它必須在給定的時間顯示多個敬酒。 爲此,我使用一個「ScheduledTaskAgent」項目。如果我添加一個任務/麪包,它正在Windows Phone上的多個預定敬酒

private static void AddToSchedule(DateTime date, string id, Toast toast) 
{ 
    PeriodicTask periodicTask = new PeriodicTask(toast.Id); 

    periodicTask.Description = toast.Title; 
    ScheduledActionService.Add(periodicTask); 
    var showIn = date - DateTime.Now; 
    ScheduledActionService.LaunchForTest(toast.Id, showIn); 
} 

protected override void OnInvoke(Microsoft.Phone.Scheduler.ScheduledTask task) 
{ 

    ShellToast toast = new ShellToast(); 
    toast.Content = task.Description; 
    toast.Show(); 

    NotifyComplete(); 

    ScheduledActionService.Remove(task.Name); 
} 

,並增加了新的任務/敬酒我做的。但是,如果我想添加更多,我有一個System.InvalidOperationException。

(表示:BNS錯誤:此類型的ScheduledAction的最大數量已被添加。)。

我該如何改變這一點,以便能夠在一項任務中添加敬酒。

更新時間:

我改變了我的AddToSchedule(),現在它的工作。

private static void AddToSchedule(DateTime date, string id, Toast toast) 
{ 
    Reminder reminder = new Reminder(toast.Id); 
    reminder.Title = toast.Title; 
    reminder.Content = toast.Title; 
    reminder.BeginTime = DateTime.Now.AddMinutes(1); 
    reminder.ExpirationTime = reminder.BeginTime.AddSeconds(5.0); 
    reminder.RecurrenceType = RecurrenceInterval.None; 
    ScheduledActionService.Add(reminder); 
} 

有沒有辦法使用烤麪包而不是提醒?

回答

1

如果你想提醒展現給用戶在一個特定的時間,你有幾種選擇:

如果你想提高從設備,您可以使用AlertReminder通知。

如果要顯示Toast通知,您必須使用Push Notification從遠程來源發送此通知。

+0

謝謝。我也這麼想。我希望能夠顯示通知(例如Toast),但要以提醒的方式顯示。 – David 2013-03-18 18:12:55

+0

號碼提醒使用提醒UI,不能顯示爲敬酒。 – 2013-03-18 18:16:23