public ProgressWidget() { ProgressMonitor = new ProgressMonitor { Handler = new ProgressWidgetMonitor(this) }; progressBar = new ProgressBar(); text = new Label(); var box = new HBox(); box.PackStart(progressBar); box.PackStart(text, true); Content = box; }
public Task RebuildIndexAsync(ProgressMonitor progressMonitor) { return Task.Run(() => { using(var progress = progressMonitor.Start("Rebuilding index...")) { cache.SwitchBuffer(); var converter = new ThreadLocal<LogEntryToDocumentConverter>(() => new LogEntryToDocumentConverter()); Parallel.ForEach(cache.ReadDataFromInactiveBuffer(progressMonitor), new ParallelOptions { MaxDegreeOfParallelism = 4 }, buffered => { writer.AddDocument(converter.Value.ToDocument(buffered)); }); writer.Commit(); searcher.Refresh(); } }); }
public IEnumerable<LogEntry> ReadDataFromInactiveBuffer(ProgressMonitor progressMonitor) { var monitoredAction = progressMonitor.Start("Reading log entries...", progressable: true); var lastUpdate = CustomDateTime.Now; switchSync.WaitOne(); try { var bufferPath = Path.Combine(TemporaryFilesManager.Instance.EmulatorTemporaryPath, string.Format("{0}.{1}", BUFFER_FILE, (currentBuffer + 1) % 2)); using(var inactiveBuffer = File.OpenRead(bufferPath)) { var primitiveReader = new PrimitiveReader(inactiveBuffer, false); var stopwatch = new Stopwatch(); stopwatch.Start(); var entriesCount = 0; LogEntry entry; while(TryDeserializeEntry(primitiveReader, out entry)) { if(stopwatch.Elapsed > TimeSpan.FromMilliseconds(50)) { monitoredAction.UpdateProgress((int)(100.0 * inactiveBuffer.Position / inactiveBuffer.Length), string.Format("Reading log entries ({0})...", Interlocked.Add(ref entriesCount, 0))); stopwatch.Restart(); } yield return entry; Interlocked.Increment(ref entriesCount); } monitoredAction.UpdateProgress(100); } } finally { switchSync.Release(); } }
public MonitoredAction(ProgressMonitor monitor, string description, bool cancelable, bool progressable) { this.monitor = monitor; Description = description; IsCancelable = cancelable; Progress = progressable ? (int?)0 : null; }
private async Task FilterEntriesAsync(ProgressMonitor progressMonitor, bool selectLastAddedItem = false) { using(var progress = progressMonitor.Start("Filtering log...")) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; var entries = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, maxPageCount * pageSize, Direction.Backward); ApplicationExtensions.InvokeInUIThread(() => { listViewLog.ClearItems(); foreach(var entry in entries.Entries) { listViewLog.AddItem(entry, selectLastAddedItem, maxPageCount * pageSize); } RefreshPaging(entries.TotalHits); }); } }
private async Task LoadEntriesAsync(ProgressMonitor progressMonitor, Direction direction, Action afterCallback = null) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; using(var progress = progressMonitor.Start("Filtering log...")) { var referenceId = (direction == Direction.Backward) ? listViewLog.FirstItemId : listViewLog.LastItemId; var entries = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, pageSize, direction, referenceId); if(entries.Entries.Any()) { if(direction == Direction.Backward) { ApplicationExtensions.InvokeInUIThread(() => { foreach(var entry in entries.Entries.Where(e => e.Id < referenceId).Reverse()) { listViewLog.InsertItem(entry, false, maxPageCount * pageSize); } }); } else { ApplicationExtensions.InvokeInUIThread(() => { foreach(var entry in entries.Entries.Where(e => e.Id > referenceId)) { listViewLog.AddItem(entry, false, maxPageCount * pageSize); } }); } } } if(afterCallback != null) { afterCallback(); } }
private async Task SearchEntriesAsync(ProgressMonitor progressMonitor, Direction direction) { using(var progress = progressMonitor.Start("Searching in log...")) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; var entries = await luceneStore.FindAsync(searchTextEntry.Text, view, 2 * pageSize, direction, searchContext != null ? searchContext.PreviousResultId : null); if(entries.Entries == null) { ApplicationExtensions.InvokeInUIThread(() => MessageDialog.ShowWarning("No results found!")); ResetSearch(false); return; } if(searchContext == null) { searchContext = new SearchContext(entries.TotalHits); } else { searchContext.Advance(direction); } searchContext.PreviousResultId = entries.FoundId; ApplicationExtensions.InvokeInUIThread(() => { listViewLog.ClearItems(); foreach(var entry in entries.Entries) { listViewLog.AddItem(entry, entries.FoundId == entry.Id); } searchLabel.Text = string.Format("Showing result: {0} / {1}", searchContext.CurrentResult, searchContext.ResultsCount); nextSearchResultButton.Sensitive = (searchContext.CurrentResult > 1); prevSearchResultButton.Sensitive = (searchContext.CurrentResult < searchContext.ResultsCount); }); } }
private EmulationManager() { var settings = new Antmicro.Migrant.Customization.Settings(Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.Method.Generated, Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldAddition | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowFieldRemoval | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowGuidChange | Antmicro.Migrant.Customization.VersionToleranceLevel.AllowAssemblyVersionChange); serializer = new Serializer(settings); serializer.ForObject<PythonDictionary>().SetSurrogate(x => new PythonDictionarySurrogate(x)); serializer.ForSurrogate<PythonDictionarySurrogate>().SetObject(x => x.Restore()); currentEmulation = new Emulation(); ProgressMonitor = new ProgressMonitor(); stopwatch = new Stopwatch(); }