我想每 10 秒后定期向 Web 服务器发出 http 请求。
我在进行 http 调用的应用程序中使用 Timer。现在,当用户按下 Windows 键时应用程序进入后台..计时器停止
我可以继续调用网络服务器吗?
我提到了 VOID 话匣子应用程序,但看起来它仅适用于 VOIP 应用程序。
问候,
SRS
我想每 10 秒后定期向 Web 服务器发出 http 请求。
我在进行 http 调用的应用程序中使用 Timer。现在,当用户按下 Windows 键时应用程序进入后台..计时器停止
我可以继续调用网络服务器吗?
我提到了 VOID 话匣子应用程序,但看起来它仅适用于 VOIP 应用程序。
问候,
SRS
您必须创建一个TaskAgent
继承自ScheduledTaskAgent
并覆盖方法的OnInvoke()
方法。您还需要将任务添加到 WMAppManifest.xml
<Deployment ...>
...
<App ...>
...
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
<ExtendedTask Name="BackgroundTask">
<BackgroundServiceAgent Name="YourTaskAgent" Type="YourNameSpace.YourTaskAgent" Source="YourTaskAgent" Specifier="ScheduledTaskAgent" />
</ExtendedTask>
</Tasks>
...
</App>
...
</Deployment>
您的主应用程序本身在暂停时无法继续执行 HTTP 请求。有关详细信息,请参阅有关后台任务的 MSDN。但是,请记住,后台任务的功能有限。希望这可以帮助。