You can open the
MessageBox
from the first form. The message box returns
DialogResult
object, which you can use for branching decisions.
Improved Answer
-----------------
As per your comment you want to show the message box just to show information and not for branching.So need to invoke a Asynchronous call. Below is an example where it invoke a busy function and then show the message box. Though message box is shown the underlying process keep going and it can finish. I put a message box at the finish to show the underlying process continues without closing the message box (button2 click) where as button 3 click waits for message box to close.
private delegate void asyncDelegate();
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
asyncDelegate del = new asyncDelegate(busyFunction);
del.BeginInvoke(new AsyncCallback(endAsynCall), del);
MessageBox.Show("Busy Process begins");
}
private void endAsynCall(IAsyncResult result)
{
asyncDelegate del =(asyncDelegate) result.AsyncState;
del.EndInvoke(result);
}
private void busyFunction()
{
for (int i = 0; i < 5; i++)
{
System.Threading.Thread.Sleep(1000);
}
MessageBox.Show("Async Process Finished");
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("Busy Process begins");
busyFunction();
}