I need to change the Label Content. but The code will sleep before execute it. So what's the different I use window execute the code or use control itself? like:
// Use Label execute
Label1.BeginInvoke(new Action(()=>{
System.Thread.Thread.Sleep(5000);
Label1.Content = "New Value";
});
// Use Window execute
MainWindow.BeginInvoke(new Action(()=>{
System.Thread.Thread.Sleep(5000);
Label1.Content = "New Value";
});
No matter I use Label or Window, it always stuck the UI when the Thread sleep. Why? Why it just don't freeze the label when we execute Label.BeginInvoke() , If Is there no any different, Why Microsoft not remove the Mothod for Control.Begininvoke()
Update1: Sorry for the Sleep(5000), I just let you know there is a method will take a lot time for execute before change the Label Content.
Update2 So If there is no any different, Then no different with Control2.BeginInvoke() and Control3.BeginInvoke() ? Then Why Microsoft just don't keep only the Window.Begininvoke()?
Update3 Why I can change the Control2.Content in Control3.BeginInvoke? If there is no limit Why All has that method? what for?
Update4 Maybe the Update2-3 is dummy qustion, sorry for that, what I mean is : If we can change the label1.content in windows.begininvoke(), why we still need label1.begininvoke()?