且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows 8 Metro风格的应用程序中,如何在未运行的情况下更新实时图块?

更新时间:2022-11-04 09:51:06

好的,让我们为您解答!这是入门的每种方法和资源.我不清楚您的情况,所以我会尽量做到通用.

Okay, let's get you answered! Here is every single way and resources for each way to get you started. Your scenario isn't clear to me, so I will try to be generic.

有四种方法可以在Windows 8中更新实时磁贴!对于主应用程序磁贴和该应用程序创建的后续辅助磁贴也是如此.

There are four ways to update a live tile in Windows 8! And this is true for the primary app tile and the subsequent secondary tiles created by the app, too.

1>首先是应用在运行时可以更新磁贴

1> The first is that the app, while running, can update the tile

但是,您正在询问如何在不运行时进行更新:

But, you were asking how to update when it is not running:

2>用户可以使用Windows 8应用程序部署后台任务.此后台任务定期执行,并且可以在其执行期间更新应用程序的磁贴.后台任务的最小频率为15分钟. Windows 8每两个小时为任务分配1个CPU秒.您的任务可以执行任意次数,直到分配完成为止.

2> A user can deploy a background task with their Windows 8 app. This background task executes periodically and can update the tile of the app during its execution. The minimum frequency of background tasks is 15 minutes. Windows 8 allocates 1 CPU second every two hours to a task. Your task can execute as often as you want until you exhaust its allocation.

3>应用程序可以在运行时打开WNS( Windows Notification Services )通道.当它不运行时,Web服务可以跨WNS推送图块更新.

3> An app can open a WNS (Windows Notification Services) channel while it is running. When it is not running, a web service can push tile updates across WNS.

  • http://msdn.microsoft.com/en-us/library/windows/apps/hh465460.aspx
  • http://visualstudiomagazine.com/articles/2012/03/25/using-push-notifications-in-windows-8.aspx
  • http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh868253(v=win.10).aspx

4>可以将图块配置为从URL提取 .定期评估该URL中的XML的增量,并在检测到该图块时对其进行刷新.默认情况下,图块会在三天后过期.

4> A tile can be configured to pull from a URL. The XML from that URL is periodically evaluated for deltas and the tile is refreshed when detected. Tiles expire by default after three days.

  • http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.startperiodicupdate.aspx
  • http://msdn.microsoft.com/en-us/library/windows/apps/hh761476.aspx

澄清点:引导操作系统时,您无法引起磁贴更新之类的事情.首先,在Windows 8中,实际上不建议使用重新启动(或至少关闭)的想法.但是您的Store应用只能以上述方式执行-不能执行上述操作,例如StartUp文件夹(过去)或RegEdit/Run(过去).但是维护或计时器触发器使您非常接近.

Point of clarification: you can't cause something like a tile update when the OS is booted. For one, in Windows 8 the idea of rebooting (or at least shutting down) is practically deprecated. But your Store app can only execute in the ways above - and can't do something like the StartUp folder (in the past) or RegEdit/Run (in the past) just the stuff above. But maintenance or timer triggers get you pretty close.

这就是答案.祝你好运,老兄!

And, that's the answer. Best of luck, dude!