private void deleteExpiredSentItemsButton_Click(object sender, RibbonControlEventArgs e) { var expiredSentItems = new ExpiredSentItems(); // Setup the progress dialog. m_progressDialog = new ProgressDialog { WindowTitle = DefaultWindowTitle, LabelContent = "Deleting..." }; m_progressDialog.Canceled += progressDialog_Canceled; m_progressDialog.Maximum = expiredSentItems.Count; // this sets up an enumeration to give us one Outlook item at a time in reverse order--suitable for deleting m_expiredMailItems = expiredSentItems.GetEnumerator(); // Start the deleting and show the progress dialog DeleteMailItem(); m_progressDialog.ShowDialog(); if (m_expiredMailItems != null) // not canceled m_expiredMailItems.Dispose(); }
private void ExplorerRibbon_Load(object sender, RibbonUIEventArgs e) { // Creating the dialog for the first time takes a while as all the WPF // assemblies need to load. So, start doing that in a background thread... // can't use QueueUserWorkItem because the AppartmentState needs to be set. var thread = new Thread(() => { var dialog = new ProgressDialog(); dialog.Visibility = System.Windows.Visibility.Hidden; dialog.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual; dialog.ShowActivated = false; dialog.Left = dialog.Top = -1000; dialog.Opacity = 0; dialog.Height = dialog.Width = 0; dialog.Loaded += (sender_, e_) => dialog.Close(); dialog.Show(); } ); thread.Priority = ThreadPriority.Lowest; thread.IsBackground = true; thread.SetApartmentState(ApartmentState.STA); thread.Start(); }