MessageBoxOptions (edit)
Remove the MessageBoxOptions.DefaultDesktopOnly parameter and it will work correctly.
DefaultDesktopOnly specifies that "The message box is displayed on the active desktop" which causes the focus loss.
https://stackoverflow.com/questions/15901047/c-windows-form-messagebox-on-top-not-working
Given an instance of your Form, you can call a MessageBox like this:
MessageBox.show(form, "Message", "Title"); (Check the doc for other parameters.)
However if you want to call this from a background thread (e.g.: BackgroundWorker) you have to use Form.Invoke() like this:
form.Invoke((MethodInvoker)delegate { MessageBox.show(form, "Message", "Title"); });
https://stackoverflow.com/questions/39387630/messagebox-not-showing-in-winforms-application-c-sharp
MessageBox.Show(this, "Message", "Caption", MessageBoxButtons.OK);
I got the message box to show on top of all other applications by calling it like so:
MessageBox.Show( "Server registered successfully!", "Gyptech Micrometer OPC Server", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
The vital part being that last parameter, MessageBoxOptions.DefaultDesktopOnly. Now the box shows over top of the installer : )
MessageBox.Show(index.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
https://stackoverflow.com/questions/16858480/messagebox-not-showing-focused-after-savefiledialog
MessageBox.Show(new Form() { WindowState = FormWindowState.Maximized, TopMost = true }, "You clicked Cancel button", "Cancel");
https://bettersolutions.com/csharp/syntax/messagebox.htm
https://www.thevbprogrammer.com/VB2010_03/03-02-Msgbox.htm
https://info.sapien.com/index.php/guis/gui-controls/spotlight-on-the-messagebox-control
Show the Wait Cursor
http://www.csharp411.com/the-proper-way-to-show-the-wait-cursor/
https://stackoverflow.com/questions/1568557/how-can-i-make-the-cursor-turn-to-the-wait-cursor
You can use Cursor.Current.
// Set cursor as hourglass Cursor.Current = Cursors.WaitCursor; // Execute your time-intensive hashing code here... // Set cursor as default arrow Cursor.Current = Cursors.Default;
However, if the hashing operation is really lengthy (MSDN defines this as more than 2-7 seconds), you should probably use a visual feedback indicator other than the cursor to notify the user of the progress. For a more in-depth set of guidelines, see this article.
Edit:
As @Am pointed out, you may need to call Application.DoEvents(); after Cursor.Current = Cursors.WaitCursor; to ensure that the hourglass is actually displayed.