如何解决如何在Javascript UWP应用程序中迭代IMapView WinRT对象?
我需要迭代对象的WinRT类型,以注销成功注册的UWP后台任务。
我有权访问该对象
javascript中的BackgroundTaskRegistration.AllTasks,但是我收到了IMapView
注意:该解决方案是使用Cordova设置的,但我是从VS2017手动连接WinRT的。
任何想法都值得赞赏!
解决方法
我尝试做同样的事情并找到了解决方案。这是示例。
const background = Windows.ApplicationModel.Background;
const allTasks = background.BackgroundTaskRegistration.allTasks;
if (allTasks.size > 0) {
let item = allTasks.first();
// item.hasCurrent should be false if the item is empty.
while (item.hasCurrent) {
const current = item.current;
const task = current.value;
// Do something with current task like
if (task.name === 'name') {
}
// move to next
item.moveNext();
}
}
希望这能奏效。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。