using System; using System.Threading.Tasks; using System.Windows.Controls; namespace SourceGit.UI { /// /// General waiting dialog. /// public partial class Waiting : UserControl { /// /// Constructor. /// public Waiting() { InitializeComponent(); } /// /// Show this dialog. /// /// /// /// public static void Show(Git.Repository repo, string tipKey, Action job) { var dialog = new Waiting(); var tip = dialog.FindResource(tipKey) as string; if (tip != null) dialog.txtTip.Text = tip; var popup = repo.GetPopupManager(); popup?.Show(dialog); popup?.Lock(); Task.Run(() => { job.Invoke(); dialog.Dispatcher.Invoke(() => { popup?.Close(true); }); }); } } }