我正在使用MS Band SDK版本 1.3.10518 ,当我尝试从后台任务启动乐队客户端时,我得到了:
BACKGROUNDTASKHOST.EXE'已退出代码1
崩溃发生在以下代码行之后:
Dim bands = Await Microsoft.Band.BandClientManager.Instance.GetBandsAsync()
我可以从Windows Phone 8.1开发者预览版的主应用程序连接到乐队。
乐队构建版本: 10.3.3213.0 09 R
答案 0 :(得分:0)
我在Sub Run中找到了与Await相关的解决方案,解决方案包括:taskInstance.GetDeferral
Public Async Sub Run(taskInstance As Background.IBackgroundTaskInstance) Implements Background.IBackgroundTask.Run
Dim deferral = taskInstance.GetDeferral
Dim bands = Await Microsoft.Band.BandClientManager.Instance.GetBandsAsync
'Other work ...
End Using
deferral.Complete()
End Sub
此外,您需要获得主应用程序的用户同意,如下所示:
bandClient.SensorManager.HeartRate.GetCurrentUserConsent
感谢:HttpClient GetAsync fails in background task on Windows 8