private void SearchWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { SearchResults = new List <SearchItem>(); var modules = DataHelpers.ModulesSearch; foreach (var item in modules) { try { var className = item.ClassName; var value = DS.Generic(className)?.Find("NameSearch", SearchMenuText, false); if (value != null) { foreach (IDocument doc in value) { SearchResults.Add(new SearchItem(doc)); NotifyOfPropertyChange("SearchResults"); } } } catch { continue; } SearchWorker.ReportProgress(0); } }
private void FileWalker_DoWork(object sender, DoWorkEventArgs e) { SearchOption o = (RecursiveSearch) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly; IEnumerable <string> files = Directory.EnumerateFiles(SelectedDirectory, "*.*", o); string currDir; string lastDir = null; foreach (string path in files) { if (SearchWorker.CancellationPending) { e.Cancel = true; break; } currDir = Path.GetDirectoryName(path); if (currDir != lastDir) { lastDir = currDir; TheWindow.SetStatusText(@$ "Searching {currDir}\..."); // TODO: path shortening func } if (SaveFileInfo.TryGetInfo(path, out SaveFileInfo info)) { SearchWorker.ReportProgress(-1, info); } } }
private void searchDoWork(object sender, DoWorkEventArgs e) { /*Búsqueda de ventas y detalle productos y pagos*/ for (int i = 0; i < numVentas; i++) { LojaDefinition lojaDefinition = lstLojaDefinition .Where(x => x.COD_FILIAL == lstLojaVenda[i].CODIGO_FILIAL).FirstOrDefault(); lstVentas.Add(new LojaVenda(lstLojaVenda[i], lojaDefinition)); SearchWorker.ReportProgress((i * 100) / numVentas, lstLojaVenda[i].TICKET + " de la tienda " + lojaDefinition.COD_FILIAL); } }
private void SearchWorkerDoWork(object sender, DoWorkEventArgs e) { var worker = sender as BackgroundWorker; var path = e.Argument as string; if (string.IsNullOrEmpty(path) || !Directory.Exists(path)) { return; } SearchWorker.ReportProgress(0, "Enumerating folders..."); var folders = new ParallelWalk().GetFolders(path); //SafeWalker.GetFolders(path); SearchWorker.ReportProgress(0, string.Format("Processing folders 0/{0}...", folders.Length)); var processed = 0; float total = folders.Length; var statusInterval = folders.Length / 100; if (worker.CancellationPending) { return; } Parallel.For(0L, folders.Length, i => { if (worker.CancellationPending) { return; } var folder = ProcessFolder(folders[(int)i]); if (folder.Size > 0) { _result.Add(folder); } Interlocked.Add(ref processed, 1); if (statusInterval > 0 && processed % statusInterval == 0) { SearchWorker.ReportProgress((int)((processed / total) * 100.0), "Processing folders (" + processed + "/" + total + ")..."); } }); SearchWorker.ReportProgress((int)((processed / total) * 100.0), "Sorting folders..."); _result.Sort(); }