public DialogScope() { _callBack = new VsThreadedWaitDialogCallback(); _callBack.Cancelled += OnCancelled; IVsThreadedWaitDialogFactory factory = (IVsThreadedWaitDialogFactory) Package.GetGlobalService(typeof(SVsThreadedWaitDialogFactory)); factory.CreateInstance(out IVsThreadedWaitDialog2 ppIVsThreadedWaitDialog); if (ppIVsThreadedWaitDialog is IVsThreadedWaitDialog4 dialog4) { _dialog = dialog4; } _dialog.StartWaitDialogWithCallback("", "", "", null, "", true, 0, true, 0, 0, _callBack); }
private async Task UseThreadedWaitDialogAsync(int currentSteps, int numberOfSteps) { if (_dialog == null) { await JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken); var factory = await GetServiceAsync(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory; Assumes.Present(factory); _dialog = factory.CreateInstance(); _dialog.StartWaitDialog("Demo", "Working on it...", "", null, "", 1, true, true); } _dialog.UpdateProgress("In progress", $"Step {currentSteps} of {numberOfSteps} completed", $"Step {currentSteps} of {numberOfSteps} completed", currentSteps, numberOfSteps, true, out _); if (currentSteps == numberOfSteps) { await Task.Delay(1000); (_dialog as IDisposable).Dispose(); } }