I've done a GUI in VisualStudio and used a TextBox to show to user what's happening.
I use myTextBox.AppendText to show information like
myTextBox.AppendText("\n" + DateTime.Now.ToLocalTime() + ": " + serviceName + " waiting for stopping");
service.Stop();
service.WaitForStatus(ServiceControllerStatus.Stopped);
service.Close();
myTextBox.AppendText("\n" + DateTime.Now.ToLocalTime() + ": " + serviceName + " has been stopped correcly");
and so on. The TextBox, anyway, is filled with the Text only when all jobs are completed. So, when all my code has finished to be run, the TextBox is filled with all the strings. So, I would like to print the string at the time I call AppendText. Are I missing anything? Maybe is anything thread-freezing like in java?
Thank you in adavnce.
Your problem is that your service calls are (apparently) running on the UI thread, so nothing will show until they have stopped blocking the thread.
You need to put your service calls on a background thread, then change your textbox text by marshalling the change up to the UI thread via the dispatcher