/// <summary> /// Shows a wait dialog. /// </summary> /// <param name="titleName">Title of the wait dialog</param> /// <param name="allowCancel">Specifies whether a cancel button should be shown.</param> /// <returns>AsynchronousWaitDialog object - you can use it to access the wait dialog's properties. /// To close the wait dialog, call Dispose() on the AsynchronousWaitDialog object</returns> public static AsynchronousWaitDialog ShowWaitDialog(string titleName, bool allowCancel) { if (titleName == null) throw new ArgumentNullException("titleName"); AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName, allowCancel); h.Start(); return h; }
/// <summary> /// Shows a wait dialog. /// </summary> /// <param name="titleName">Title of the wait dialog</param> /// <param name="allowCancel">Specifies whether a cancel button should be shown.</param> /// <returns>AsynchronousWaitDialog object - you can use it to access the wait dialog's properties. /// To close the wait dialog, call Dispose() on the AsynchronousWaitDialog object</returns> public static AsynchronousWaitDialog ShowWaitDialog(string titleName, bool allowCancel) { if (titleName == null) { throw new ArgumentNullException("titleName"); } AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName, allowCancel); h.Start(); return(h); }
/// <summary> /// Shows a wait dialog that does supports cancelling. /// </summary> /// <param name="titleName">Title of the wait dialog</param> /// <param name="defaultTaskName">The default description text, if no named task is active.</param> /// <param name="action">The action to run within the wait dialog</param> public static void RunInCancellableWaitDialog(string titleName, string defaultTaskName, Action <AsynchronousWaitDialog> action) { if (titleName == null) { throw new ArgumentNullException("titleName"); } using (AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName, defaultTaskName, true)) { h.Start(); try { action(h); } catch (OperationCanceledException ex) { // consume OperationCanceledException if (ex.CancellationToken != h.CancellationToken) { throw; } } } }
/// <summary> /// Shows a wait dialog that does supports cancelling. /// </summary> /// <param name="titleName">Title of the wait dialog</param> /// <param name="defaultTaskName">The default description text, if no named task is active.</param> /// <param name="action">The action to run within the wait dialog</param> public static void RunInCancellableWaitDialog(string titleName, string defaultTaskName, Action<AsynchronousWaitDialog> action) { if (titleName == null) throw new ArgumentNullException("titleName"); using (AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName, defaultTaskName, true)) { h.Start(); try { action(h); } catch (OperationCanceledException ex) { // consume OperationCanceledException if (ex.CancellationToken != h.CancellationToken) throw; } } }