private void StartWaitDialogHelper(string caption, string waitMessage, string progressText, int delayToShowDialog, bool isCancellable, bool isProgressVisible, int currentStepCount = 0, int totalStepCount = -1, IWaitDialogCallback callback = null) { if (!ThreadHelper.CheckAccess()) { ThreadHelper.Generic.Invoke(() => { StartWaitDialogHelper(caption, waitMessage, progressText, delayToShowDialog, isCancellable, isProgressVisible, currentStepCount, totalStepCount, callback); }); } else { ThreadHelper.ThrowIfNotOnUIThread(nameof(StartWaitDialogHelper)); lock (_syncObject) { if (_instance == null) { _instance = WaitDialog.AcquireInstance(); } if (_instance == null) { _isDialogStarted = true; } else { _isUiSuppressed = IsUiSuppressed(); if (!_isUiSuppressed) { try { var args = new DialogShowArguments(caption, waitMessage, progressText, isCancellable, isProgressVisible, currentStepCount, totalStepCount) { AppMainWindowHandle = GetPrimaryWindowHandle() }; _instance.Show(TimeSpan.FromSeconds(delayToShowDialog), args, callback); _isDialogStarted = true; } catch { WaitDialog.ReleaseInstance(_instance); _instance = null; throw; } } else { _isDialogStarted = true; } } } } }
private void ReleaseDialogInstance() { lock (_syncObject) { if (_instance == null) { return; } WaitDialog.ReleaseInstance(_instance); _instance = null; } }