Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Phone 8.1 Silverlight地理围栏_C#_Silverlight_Geolocation_Windows Phone 8.1_Geofencing - Fatal编程技术网

C# 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

我正在尝试为windows phone 8.1 silverlight开发地理围栏应用程序。我已经在Windows Phone 8.1中开发了一个应用程序,而不是Silverlight。以下是该代码

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”。