private void ListFilesUsingColor() { enhmb = new EnhancedMessageBox(); enhmb.StartPosition = FormStartPosition.Manual; enhmb.Location = new Point(this.Location.X, this.Location.Y); enhmb.SetText("Processing files.\nThis may take a few seconds."); enhmb.SetCaption("Processing files."); enhmb.ProgressBarVisible(true); enhmb.button_OK_text("Abort"); enhmb.Show(); Cursor.Current = Cursors.WaitCursor; Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation int filescount = this.listView_MainFileList.SelectedItems.Count; enhmb.ProgressBarSize(filescount); int pb = 0; foreach (ListViewItem item in this.listView_MainFileList.SelectedItems) { pb++; enhmb.SetText("Processing files.\nThis may take a few seconds.\n\nFile: " + item.Text); enhmb.ProgressBarValue((int)pb); Application.DoEvents(); //accept user input and when the messagebox is closed, stop working if (enhmb.Visible == false) { break; } item.Selected = CSHaPer.IsColorUsed(item.Tag.ToString(), (byte)this.uC_EditorPalette1.PaletteSelectedColor); }//foreach file enhmb.Close(); Application.DoEvents(); //finish showing the dialog before starting the cpu-intensive operation Cursor.Current = Cursors.Default; //create result file string result = ""; result = "Files using color result\r\n"; result += this.listView_MainFileList.SelectedItems.Count.ToString() + " Files found, using the color [" + this.uC_EditorPalette1.PaletteSelectedColor.ToString() + "]\r\n\r\n"; for (int i = 0; i < this.listView_MainFileList.SelectedItems.Count; i++) { result += this.listView_MainFileList.SelectedItems[i].Text + "\r\n"; } System.IO.File.WriteAllText(defaultPath + "#ColorUsage.txt", result); System.Diagnostics.Process.Start(defaultPath + "#ColorUsage.txt"); }