我有一个相当简单的问题。HTTPWebRequest唤醒WIFI?
我们使用BackgroundAgents(Periodic agents)执行一些后台任务,这些任务需要WiFi(互联网)连接才能执行HttpWebRequest。正如在第二个参考中提到的HttpWebRequest被支持,但问题是,如果Windows Phone被锁定或闲置超过1分钟,WiFi被禁用。
我已经基于两个重要的问题是什么我已阅读并尝试,直到知道:
- 微软是否能够定期按照预定的时间间隔来检查新邮件或其他通知的WiFi?如果答案是肯定的,我的后台代理会在这段时间内重新安排并运行吗?
- 直到知道我发现,如果被锁定的HttpWebRequest不唤醒手机,或在闲置超过1分钟。是这样吗?很多人声明,如果手机被锁定或者1分钟过去了,HttpWebRequest可以正常工作。我无法做到这一点。
谢谢。
示例代码:
protected override void OnInvoke(ScheduledTask task)
{
ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(120));
MakeHttpRequest("test");
}
private void MakeHttpRequest(string position)
{
if (position != null)
{
var request = (HttpWebRequest)WebRequest.Create(
new Uri("http://mydomain.com/Testing/Details/"+position));
request.BeginGetResponse(r =>
{
var httpRequest = (HttpWebRequest)r.AsyncState;
var httpResponse = (HttpWebResponse)httpRequest.EndGetResponse(r);
using (var reader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = reader.ReadToEnd();
Deployment.Current.Dispatcher.BeginInvoke(new Action(() =>
{
}));
}
}, request);
}
this.NotifyComplete();
}
PS:请记住,当我运行这段代码,而应用程序是使用USB电缆都连接到计算机上运行良好。这就是为什么我相信它的后台工作人员不能唤醒手机+ WiFi以执行HttpWebRequest的问题。
请出示一些源代码...你尝试过什么? – Yahia 2012-04-20 18:18:28
谢谢@Yahia。添加了源代码! – glarkou 2012-04-20 18:23:24
您正在使用哪个BackgroundAgent类? – 2012-04-20 18:29:44