Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I'm working in a project and I want that when my first form processing starts my second form shows, and customer must click the second form if they want to go to first form.
(I want something like messagebox.)

We must have click on the messagebox.

Please suggest your Ideas?
Posted
Updated 26-Mar-11 2:45am
v3
Comments
Dalek Dave 26-Mar-11 8:45am    
Edited for Grammar, Spelling and Readability.

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.

C#
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();
}
 
Share this answer
 
v2
Comments
situ21 26-Mar-11 2:39am    
I good but I don't want to stop processing of my first form, it should be work in background.
please help me
Albin Abel 26-Mar-11 9:20am    
Look at my improved answer
Dalek Dave 26-Mar-11 8:46am    
Seems reasonable.
Albin Abel 26-Mar-11 9:20am    
Thanks Dalek Dave
I think you want
C#
DialogResult dr = MessageBox.Show("Message", "Look", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
 if (dr != DialogResult.OK)
 {
   MessageBox.Show("done"); 
 }


message box will show two button Ok and Cancel, you can do accordingly
 
Share this answer
 
Comments
Dalek Dave 26-Mar-11 8:46am    
Good Call
[no name] 28-Mar-11 1:07am    
Thanx
You need Form.ShowDialog.

Read about it with sample example here: Form.ShowDialog Method[^]

Sample article on the same: Displaying and Working with Forms[^]

You second form is ShowDialog and one need to click second form close to go back to first one. Try!
 
Share this answer
 
v2
Comments
situ21 26-Mar-11 2:39am    
I good but I don't want to stop processing of my first form, it should be work in background. please help me
Sandeep Mewara 26-Mar-11 3:29am    
Are you saying processing or access? If processing then it can be continued but not accessed until you close the dailog.
situ21 26-Mar-11 4:23am    
i want processing continue, but after use showdialog,it stop processing,

so what i use for this
Sandeep Mewara 26-Mar-11 5:10am    
Just run a separate thread!
situ21 26-Mar-11 5:20am    
how

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900