I need a method to pause my code for a certrain time like: Sleep(1000)
I found Thread.Sleep(); but it only pauses the GUI and my programm runs in the background. Furthermore I found some timer functions that only work in windows form, not in WPF.
The answers from this feed didn´t work as well: How to put delay before doing an operation in WPF
None of them shows a error message but also none of them delays my programm.
//The code I want to run:
for (int i = 5; i>0; i--)
{
win_label_test.Content = i;
Sleep(1000);
}
//The Code I used that didn´t work
Thread.Sleep(1000);
//Only pauses the GUI not the programm so there is no output and after 5 seconds it displays "1"
Task.WaitAll(new Task[] { Task.Delay(2000) });
// Same problem as with Thread.Sleep();