예제 #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();
     }
 }
예제 #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);
     }
 }
예제 #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();
     }
 }
예제 #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);
     }
 }
예제 #5
0
 private static T ExecuteFunction <T>(UiProgressWindow window, Func <T> func)
 {
     try
     {
         return(func());
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
예제 #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);
     }
 }
예제 #7
0
 private static void ExecuteAction(UiProgressWindow window, Action action)
 {
     try
     {
         action();
     }
     finally
     {
         window.Dispatcher.Invoke(window.Close);
     }
 }
예제 #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);
     }
 }