C# Windows Phone 8.1 Silverlight地理围栏
我正在尝试为windows phone 8.1 silverlight开发地理围栏应用程序。我已经在Windows Phone 8.1中开发了一个应用程序,而不是Silverlight。以下是该代码C# Windows Phone 8.1 Silverlight地理围栏,c#,silverlight,geolocation,windows-phone-8.1,geofencing,C#,Silverlight,Geolocation,Windows Phone 8.1,Geofencing,我正在尝试为windows phone 8.1 silverlight开发地理围栏应用程序。我已经在Windows Phone 8.1中开发了一个应用程序,而不是Silverlight。以下是该代码 private async void MonitorOnGeofenceStateChanged(GeofenceMonitor sender, object args) { //IReadOnlyCollection<GeofenceStateChangeRepor
private async void MonitorOnGeofenceStateChanged(GeofenceMonitor sender, object args)
{
//IReadOnlyCollection<GeofenceStateChangeReport> reports = GeofenceMonitor.Current.ReadReports();
var reports = sender.ReadReports();
await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
{
foreach (GeofenceStateChangeReport changeReport in reports)
{
if (changeReport.NewState == GeofenceState.Entered)
{
Dispatcher.RunAsync(CoreDispatcherPriority.High, async () =>
{
MessageDialog dialog = new MessageDialog("u re in the location");
await dialog.ShowAsync();
});
}
}
});
}
但是当我在silverlight 8.1中尝试这段代码时,它在Dispatcher.RunAsyncCoreDispatcherPriority.High中给出了一个错误,async=>
所以我试着用Dispatcher.BeginInvoke=>替换它。但随后geaofencing通知并没有出现。我找不到解决这个问题的有效方法 您不需要在另一个内部使用一个dispatcher调用,一个外部dispatcher.RunAsync调用就足够了。到底是哪一个问题困扰着您,您遇到了什么类型的错误?RunAsync方法在windows phone 8.1 Silverlight中不可用。但如果没有这一点,地理围栏技术就不会出现。错误是;System.Windows.Threading.Dispatcher不包含“RunAsync”的定义,并且找不到接受类型为“System.Windows.Threading.Dispatcher”的第一个参数的扩展方法“RunAsync”。