(Edit - This is for learning purposes only the program is completely pointless)
I'm trying to make it look like my program is loading using Thread.Sleep()
with a randomly generated number. It works and it waits the time but for some reason it will not display the history variable on screen until after all of the sleeps have happened.
It should do this
- Print logging in...
- Sleep for 5-10 seconds
- print verifying details...
- sleep for 5-10 seconds
- print Logged in.
The reason I am appending the history string is because I want to keep all previous prints on the screen and I'm new to programming so I thought this is the easiest way.
private void Loading()
{
Random rnd = new Random();
int wait1 = rnd.Next(5000, 10000 );
history = "Logging in...\n";
historyLbl.Text = history;
System.Threading.Thread.Sleep(wait1);
int wait2 = rnd.Next(5000, 10000);
history = history + "Verifying Details...\n";
historyLbl.Text = history;
System.Threading.Thread.Sleep(wait2);
history = history + "Logged in.\n";
historyLbl.Text = history;
}