As you can see into my code example, when user clicks on Button1
, an application starts and program waits until its process name shows up in the processes list.
My "problem" is with the Label1.Text
before
Process.Start(@"\application.exe");
Αlthough this.Cursor = Cursors.WaitCursor;
works fine, the label doesn't get the updated with the text "Please wait..." while waiting.
What am I doing wrong?
private void Button1_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("Do you want to start the application?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
this.Cursor = Cursors.WaitCursor;
Label1.Text = "Please wait...";
Process.Start(@"\application.exe");
Process[] processes;
do
{
processes = Process.GetProcessesByName("applicationname");
Thread.Sleep(500);
}
while (processes.Length == 0);
this.Cursor = Cursors.Default;
Label1.Text = "Done!!!";
}
}