2015-10-02 6 views
6

私はTimeTriggerを使用して計算しましたが、Windows 10(UWP)のスケジュールされたバックグラウンドタスクの方法です。しかし、最低限必要なのは15分です。ちょうど私たちが次の1分間実行するようにスケジュールを設定しても、Windows 10のアラームとリマインダがどのように機能するのか不思議です。Windows 10(UWP)のTimeTrigger/Schedulerが15分未満

私は、15分未満の時間を含む特定の時間にタスクを起動する必要があるソリューションを探しています。

誰でもこのことを少し気にすることはできますか?

+0

アラームとリマインダーが異なります。それらのために 'TimeTrigger'は必要ありません。 http://stackoverflow.com/questions/31740884/can-i-create-an-alarm-app-for-window-universal-app –

+0

私はGithubのサンプルコードを調べ、Alarmと他のトーストが表示されていることがわかりましたボタンのクリックに基づいています。 Foregroundアプリが動作していなくても動作するタイマーに、これをどのようにアタッチできるのか分かりますか?私は、スケジュールされた時間にどのように実行されるかはわかりません。それはJeffreyが指摘したように "ToastNotificationManager.CreateToastNotifier()。AddToSchedule"によって行われますか? Github Windows 10サンプルのコードは? –

+0

このような方法でコードブロックをスケジュール実行する方法については、ユーザーが選択した時間に基づいて15分未満である可能性があります。 –

答えて

4

アラーム&クロックアプリケーションは、バックグラウンドタスクではなくスケジュールトースト通知を使用していました。ここ

enter image description here

10秒でトーストをスケジュールするためのサンプルコードです。

namespace UWPApp 
{ 
    /// <summary> 
    /// An empty page that can be used on its own or navigated to within a Frame. 
    /// </summary> 
    public sealed partial class MainPage : Page 
    { 
     private Random random = new Random((int)DateTime.Now.Ticks); 

     const string TOAST = @" 
<toast> 
    <visual> 
    <binding template=""ToastGeneric""> 
     <text>Sample</text> 
     <text>This is a simple toast notification example</text> 
     <image placement = ""AppLogoOverride"" src=""oneAlarm.png"" /> 
    </binding> 
    </visual> 
    <actions> 
    <action content = ""check"" arguments=""check"" imageUri=""check.png"" /> 
    <action content = ""cancel"" arguments=""cancel""/> 
    </actions> 
    <audio src =""ms-winsoundevent:Notification.Reminder""/> 
</toast>"; 


     public MainPage() 
     { 
      this.InitializeComponent(); 
     } 

     private void Button_Click(object sender, RoutedEventArgs e) 
     { 
      var when = DateTime.Now.AddSeconds(10); 

      var offset = new DateTimeOffset(when); 

      Windows.Data.Xml.Dom.XmlDocument xml = new Windows.Data.Xml.Dom.XmlDocument(); 

      xml.LoadXml(TOAST); 

      ScheduledToastNotification toast = new ScheduledToastNotification(xml, offset); 

      toast.Id = random.Next(1, 100000000).ToString(); 

      ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); 
     } 
    } 
} 
+0

私は参照してください。では、これはバックグラウンドで実行されますか?フォアグラウンドアプリが実行されていなくてもAddToScheduleを実行できますか? 10分以内にコードブロックを実行できる方法はありますか? –

+0

このような方法でコードブロックをスケジュールする方法については、ユーザーが選択した時間に基づいて15分未満である可能性があります。 –

+0

これは実際にアラームとそのタイミングに関する私の質問に答えるものです。答えとしてマークする。 –

関連する問題