Example #1
0
 public static void Execute(string title, Action <Action <long>, Action <long> > action, UiProgressUnits units = UiProgressUnits.Items)
 {
     using (UiProgressWindow window = new UiProgressWindow(title, units))
     {
         Task.Run(() => ExecuteAction(window, action));
         window.ShowDialog();
     }
 }
Example #2
0
 public static T Execute <T>(string title, Func <Action <long>, Action <long>, T> action, UiProgressUnits units = UiProgressUnits.Items)
 {
     using (UiProgressWindow window = new UiProgressWindow(title, units))
     {
         Task <T> task = Task.Run(() => ExecuteFunction(window, action));
         window.ShowDialog();
         return(task.Result);
     }
 }
Example #3
0
 public static void Execute(string title, IProgressSender progressSender, Action action, UiProgressUnits units = UiProgressUnits.Items)
 {
     using (UiProgressWindow window = new UiProgressWindow(title, units))
     {
         progressSender.ProgressTotalChanged += window.SetTotal;
         progressSender.ProgressIncremented  += window.Incremented;
         Task.Run(() => ExecuteAction(window, action));
         window.ShowDialog();
     }
 }
Example #4
0
 private static T ExecuteFunction <T>(UiProgressWindow window, Func <Action <long>, Action <long>, T> action)
 {
     try
     {
         return(action(window.SetTotal, window.Incremented));
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
Example #5
0
 private static T ExecuteFunction <T>(UiProgressWindow window, Func <T> func)
 {
     try
     {
         return(func());
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
Example #6
0
 private static void ExecuteAction(UiProgressWindow window, Action <Action <long>, Action <long> > action)
 {
     try
     {
         action(window.SetTotal, window.Incremented);
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
Example #7
0
 private static void ExecuteAction(UiProgressWindow window, Action action)
 {
     try
     {
         action();
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
Example #8
0
 public static T Execute <T>(string title, IProgressSender progressSender, Func <T> func, UiProgressUnits units = UiProgressUnits.Items)
 {
     using (UiProgressWindow window = new UiProgressWindow(title, units))
     {
         progressSender.ProgressTotalChanged += window.SetTotal;
         progressSender.ProgressIncremented  += window.Incremented;
         Task <T> task = Task.Run(() => ExecuteFunction(window, func));
         window.ShowDialog();
         return(task.Result);
     }
 }