Beacons.Universal.Background.MainPage.OnBackgroundTaskCompleted C# (CSharp) Метод

OnBackgroundTaskCompleted() приватный Метод

private OnBackgroundTaskCompleted ( BackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs eventArgs ) : void
task Windows.ApplicationModel.Background.BackgroundTaskRegistration
eventArgs Windows.ApplicationModel.Background.BackgroundTaskCompletedEventArgs
Результат void
        private async void OnBackgroundTaskCompleted(BackgroundTaskRegistration task, BackgroundTaskCompletedEventArgs eventArgs)
        {
            // We get the advertisement(s) processed by the background task
            if (ApplicationData.Current.LocalSettings.Values.Keys.Contains(taskName))
            {
                string backgroundMessage = (string)ApplicationData.Current.LocalSettings.Values[taskName];


                var bytes = Encoding.Unicode.GetBytes(backgroundMessage);
                var serializer = new DataContractJsonSerializer(typeof(List<iBeaconData>));

                var foundBeacons = (List<iBeaconData>)serializer.ReadObject(new MemoryStream(bytes));

                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    foreach (var beacon in foundBeacons)
                    {
                        var existing = beacons.Where(b => b.UUID == beacon.UUID && b.Major == beacon.Major && b.Minor == beacon.Minor).FirstOrDefault();
                        if (existing != null)
                        {
                            var idx = beacons.IndexOf(existing);
                            beacons.RemoveAt(idx);
                            beacons.Insert(idx, beacon);
                        }
                        else
                            beacons.Add(beacon);
                    }

                    txtTimeStamp.Text = DateTime.FromBinary((long)ApplicationData.Current.LocalSettings.Values[taskName + "TimeStamp"]).ToString();
                });
            }
        }