public void Stop(string operationId) { WpfUtilities.Post(new DispatchAction { Dispatcher = _progressBar.Dispatcher, Delay = TimeSpan.FromSeconds(0.1), Action = () => StopWorker(operationId) }); }
/// <summary> /// Enqueue a progress bar request for the given operation id. /// The progress bar will be shown only after a short delay (.5 sec). /// </summary> public void Start(string operationId, string toolTipText) { var item = AddOrUpdateOperation(operationId, toolTipText); // Start a new one WpfUtilities.Post(new DispatchAction { Dispatcher = _progressBar.Dispatcher, Delay = TimeSpan.FromSeconds(0.3), Action = () => StartWorker(item) }); }
private static T TryAction <T>(DispatcherObject dispatcher, Action action, Func <T> func, int maxLoops) where T : class { for (var i = 0; i < maxLoops; i++) { action(); var result = WpfUtilities.Invoke(dispatcher, DispatcherPriority.Background, func); if (result != null) { return(result); } } return(null); }