加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

Windows 10(UWP)中的TimeTrigger/Scheduler不到15分钟

发布时间:2020-12-14 02:27:03 所属栏目:Windows 来源:网络整理
导读:我发现使用TimeTrigger是 Windows 10(UWP)上预定后台任务的方式.但是看起来我们需要给出的最小数量是15分钟.只是想知道,警报和提醒如何适用于Windows 10,即使我们计划在接下来的1分钟内运行它. 我正在寻找一个应该在特定时间内触发任务的解决方案,其中包括不
我发现使用TimeTrigger是 Windows 10(UWP)上预定后台任务的方式.但是看起来我们需要给出的最小数量是15分钟.只是想知道,警报和提醒如何适用于Windows 10,即使我们计划在接下来的1分钟内运行它.

我正在寻找一个应该在特定时间内触发任务的解决方案,其中包括不到15分钟.

任何人都可以对此有所了解吗?

解决方法

报警&时钟应用程序使用预定的Toast通知而不是后台任务.

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);
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读