public void BeginImportDirectory(string path, ImportStatusUpdateDelegate importStatusUpdateCallback) { this.importStatusUpdateCallback = importStatusUpdateCallback; InitializeImport(path); MethodInvoker invoker = new MethodInvoker(ImportDirectory); AsyncCallback callback = new AsyncCallback(EndImportDirectory); invoker.BeginInvoke(callback, null); }
private void importStatusUpdated(object sender, ImportStatusUpdateEventArgs args) { if (InvokeRequired) { ImportStatusUpdateDelegate updateDelegate = new ImportStatusUpdateDelegate(importStatusUpdated); Invoke(updateDelegate, new object[]{sender, args}); } else { currentStatusToolStripLabel.Text = string.Format("Importing: [{0}/{1}/{2}] {3}", args.ImportCount, args.ScanCount, args.ErrorCount, args.Path); if (args.Completed) { MessageBox.Show(string.Format("Files Imported: {0}\nFiles Scanned: {1}\nErrors: {2}\nTime Elapsed: {3}", args.ImportCount, args.ScanCount, args.ErrorCount, args.CompletedTime), "IMPORT COMPLETED"); } } }
private void importCatalogToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(lastDirectoryOpened)) lastDirectoryOpened = ContextHelper.GetPlaylistDirectory(); if (Directory.Exists(lastDirectoryOpened)) DirectoryOpenDialog.SelectedPath = lastDirectoryOpened; DialogResult result = DirectoryOpenDialog.ShowDialog(); if (result == DialogResult.OK) { ImportStatusUpdateDelegate updateCallback = new ImportStatusUpdateDelegate(importStatusUpdated); taskController.BeginImportDirectory(DirectoryOpenDialog.SelectedPath, updateCallback); lastDirectoryOpened = DirectoryOpenDialog.SelectedPath; } }