public void OpDlgTest() { var idlg = new IOperationsProgressDialog(); idlg.StartProgressDialog(IntPtr.Zero, OPPROGDLGF.OPPROGDLG_DEFAULT); idlg.SetOperation(SPACTION.SPACTION_FORMATTING); idlg.SetMode(PDMODE.PDM_RUN); idlg.UpdateProgress(0, 0, 0, 0, 0, 100); var srcd = new Vanara.Windows.Shell.ShellFolder(KNOWNFOLDERID.FOLDERID_Documents); var destd = new Vanara.Windows.Shell.ShellFolder(KNOWNFOLDERID.FOLDERID_Desktop); idlg.UpdateLocations(srcd.IShellItem, destd.IShellItem); var rnd = new Random(); for (uint i = 0; i < 100; i++) { if (idlg.GetOperationStatus() == PDOPSTATUS.PDOPS_CANCELLED) { break; } idlg.UpdateProgress(i * 1024, 102400, i * 1024, 102400, i, 100); Thread.Sleep(rnd.Next(50, 250)); } idlg.StopProgressDialog(); }
private void _backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { int hr = _dialog.StopProgressDialog(); Marshal.ThrowExceptionForHR(hr); Marshal.ReleaseComObject(_dialog); _dialog = null; OnRunWorkerCompleted(new RunWorkerCompletedEventArgs(!e.Cancelled && e.Error == null ? e.Result : null, e.Error, e.Cancelled)); }
/// <summary> /// Closes the dialog. /// </summary> public async void Close() { if (_nativeProgressDialog != null && dialogStatus != DIALOGSTATUS.DLG_DISPOSED) { _nativeProgressDialog.StopProgressDialog(); dialogStatus = DIALOGSTATUS.DLG_DISPOSED; await Task.Delay(900); Marshal.FinalReleaseComObject(_nativeProgressDialog); _nativeProgressDialog = null; } }