There is a power button in WPF, which should start the loading screen (the screen.STARTScreen() function), after which the text blocks will be filled with data, and after 5 seconds the screen.WRITE() function should be called, which will update the data in the text blocks. The problem is that when I press the button, the 2nd function immediately triggers after 5 seconds. I understand that everything works, but not as intended. Changes to the text blocks occur immediately, and only the Red_Click event itself stops.
WPF .NET 4.5 The functions are attached.
public void STARTScreen (ArrayMenu menu, List<TextBox> screenList, ref string LEVEL)
{
screenList[0].Text = "0";
screenList[1].Text = "1";
screenList[2].Text = "2";
screenList[3].Text = "3";
}
private void Red_Click(object sender, RoutedEventArgs e)
{
screen.STARTScreen(menu, screenList, ref LEVEL);
screen.WAIT(5000);
screen.WRITE(menu, screenList, ref LEVEL);
}
public void WAIT(int milisec)
{
Task.Run(async delegate { await Task.Delay(milisec); }).Wait();
}
public void WRITE(ArrayMenu menu, List<TextBox> screenList, ref string LEVEL)
{
screenList[0].Text = menu.getValue(LEVEL);
screenList[1].Text = menu.getValue(menu.NextKeyOfAddress(ref LEVEL));
screenList[2].Text = menu.getValue(menu.NextKeyOfAddress(ref LEVEL));
screenList[3].Text = menu.getValue(menu.NextKeyOfAddress(ref LEVEL));
}