示例#1
0
 public void Stop(string operationId)
 {
     WpfUtilities.Post(new DispatchAction {
         Dispatcher = _progressBar.Dispatcher,
         Delay      = TimeSpan.FromSeconds(0.1),
         Action     = () => StopWorker(operationId)
     });
 }
示例#2
0
        /// <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)
            });
        }
示例#3
0
 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);
 }