Click here to Skip to main content
15,908,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hellow
in the code below ,i want to show a message to the user saying that he/she should wait for few seconds
while the program is busy in detecting whether the microsoft word is working or not
when program finish detecting the above message should disappear
see this code
C#
//MyMessage("Please wait");//<-------- line A
    foreach (System.Diagnostics.Process instance in Process.GetProcesses())
    {
        if (instance.ProcessName == "WINWORD")
        {
             flage = 1;
        }
    }
    //MyMessage should disappear here//<--- line B

what should i write in both line A and line B
thanks
Posted

The way I would do it is to create a form which holds the message and which either does the GetProcesses in a background thread or in the Shown event handler (background is better) and closes when it is done.
You then use ShowDialog on the message form in your main form and it returns when the form closes so you can get the result.
 
Share this answer
 
Comments
Engineer khalid 14-Jul-14 5:40am    
i have never don some thing in the back groud but i shall read in the msdn,i appreciate if you refer me to an example for the backgroud, the reason i am in short time
Engineer khalid 14-Jul-14 5:56am    
does the back ground be attach to the form.cs Designer like the way we do as Load,click,KeyDown,KeyPress,FormClosed,FormClosing,Enter in the property menue or is it just a method like

private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
// This method runs on the main thread.
Words.CurrentState state =
(Words.CurrentState)e.UserState;
this.LinesCounted.Text = state.LinesCounted.ToString();
this.WordsCounted.Text = state.WordsMatched.ToString();
}
?
You should put the 'detecting part' of your program on a worker thread in order to keep the GUI responsive. Have a look at Threading (MSDN)[^].
 
Share this answer
 

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