Under WPF, the Label control does not have any method of Refresh (). So now the question is coming.
Let's say there's a scenario where a button, a label, a button is pressed to trigger a time-consuming operation on a WPF form, and before the action, the label displays a message saying what to do now.
As a result, the button press down, the system will be busy, and the label should be displayed first, but did not show, until the time-consuming operation has been completed before the sudden display.
This is not science, completely lost the meaning of the hint. is clearly label. Content = "Try to connect with the server, please wait ..." "; Execution first, how the result is late.
The reason is not to delve into. I'm not interested in WPF either. WPF is so willful. The solution is to put time-consuming operations into a new thread:
Loginwindow Loginwin;
Socketioclient client;
Please wait while private void Button_Click (object sender, RoutedEventArgs e)
{
labinfo.content = "Try to connect to the server ..." ";
btnlogin.isenabled = false;
Thread thr = null;
THR = new Thread (new ThreadStart (buildconnection));
Thr. Priority = threadpriority.lowest;
Thr. IsBackground = true;
Thr. Start ();
}
void Buildconnection ()
{
client = new Socketioclient ();
Client. onconnected + = login;
Client. Onauthok + = Authok;
Client. Execute ();
}