gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 08:02:58 28 4
gpt4 key购买 nike

我发现使用 TimeTrigger 是 Windows 10 (UWP) 上计划后台任务的方式。但是看起来我们需要给出的最小数字是 15 分钟。只是想知道,即使我们安排它在接下来的 1 分钟内运行,警报和提醒如何在 Windows 10 上工作。

我正在寻找一种解决方案,该解决方案应该在特定时间(包括少于 15 分钟)内触发任务。

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

最佳答案

闹钟应用程序使用的是预定 Toast 通知而不是后台任务。

enter image description here

这是在 10 秒内安排 Toast 的示例代码。

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

关于scheduler - Windows 10 (UWP) 中的 TimeTrigger/Scheduler 不到 15 分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32899713/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com