private void PLLoadList_Click(object sender, RoutedEventArgs e) { M3UFile _m3uFile = new M3UFile(); using (var ofd = new OpenFileDialog { Filter = "M3U File (*.m3u)|*.m3u", Title = "Open Playlist" }) { if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { Task task2 = Task.Run(new Action(() => { _m3uFile.Load(ofd.FileName); foreach (var entry in _m3uFile) { AAPList plist = new AAPList(entry, AAPLists.Count); playlistgrid.Dispatcher.BeginInvoke(new Action(() => AAPLists.Add(plist))); } Save(); })); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } if (_m3uFile != null) { } } } }