async Task LoadEntries() { try { if (IsBusy) { return; } IsBusy = true; LogEntries.Clear(); ReadLibraries readLibraries = new ReadLibraries(); List <string> libraries = readLibraries.libraries; var tempEntries = new List <PlugEVMeEntry>(); tempEntries.Add(homeEntry); foreach (string library in libraries) { PlugEVMeEntry _entry = new PlugEVMeEntry(); string[] libs = library.Split(','); _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]); _entry.Latitude = Convert.ToDouble(libs[libs.Length - 2]); libs.Take(libs.Length - 1); libs.Take(libs.Length - 2); _entry.Title = libs[0]; _entry.Date = DateTime.Now; _entry.Title = string.Join(" ", libs); _entry.Notes = _entry.Latitude + " " + _entry.Longitude; tempEntries.Add(_entry); } // AddRange() in ObservableRangeCollection differs from Add() in ObservableCollection in that it fires a single // CollectionChanged notification when all the items are added to the collection at once, instead of many individual // CollectionChanged notifications from calling Add() over and over. LogEntries.AddRange(tempEntries); } finally { IsBusy = false; } await Task.CompletedTask; }
void LoadEntries() { if (IsBusy) { return; } IsBusy = false; LogEntries.Clear(); try { ReadLibraries readLibraries = new ReadLibraries(); List <string> libraries = readLibraries.libraries; // Load the current position homeentry and test values LogEntries.Insert(0, homeEntry); foreach (string library in libraries) { PlugEVMeEntry _entry = new PlugEVMeEntry(); string[] libs = library.Split(','); _entry.Longitude = Convert.ToDouble(libs[libs.Length - 1]); _entry.Latitude = Convert.ToDouble(libs[libs.Length - 2]); libs.Take(libs.Length - 1); libs.Take(libs.Length - 2); _entry.Title = libs[0]; _entry.Date = DateTime.Now; _entry.Title = string.Join(" ", libs); _entry.Notes = _entry.Latitude + " " + _entry.Longitude; LogEntries.Add(_entry); } } finally { IsBusy = false; } }