public static Object RunTask(TASKFUNCTION task, Window parentWindow = null, string windowTitle = null) { using (var dlg = new TaskMonitorDialog()) { if (parentWindow == null) { parentWindow = Application.Current.MainWindow; } dlg.Owner = parentWindow; dlg.Icon = parentWindow.Icon; dlg.Title = !string.IsNullOrEmpty(windowTitle) ? windowTitle : parentWindow.Title; dlg._Task = task; dlg._Result = null; dlg.ShowDialog(); dlg.Owner = null; var result = dlg._Result; if (result is Exception) { throw new InvalidOperationException("Task Failed", result as Exception); } return(result); } }
public static void RunTask <T>(TASKACTION task, Window parentWindow = null, string windowTitle = null) where T : TaskMonitorWindow, new() { if (task == null) { throw new ArgumentNullException(nameof(task)); } TASKFUNCTION func = (c, p) => { task(c, p); return(null); }; RunTask <T>(func, parentWindow, windowTitle); }
public static void RunTask(TASKACTION task, Window parentWindow = null, string windowTitle = null) { TASKFUNCTION func = (c, p) => { task(c, p); return(null); }; RunTask(func, parentWindow, windowTitle); }