So I have this Progress Bar that I'm changing the value of after each sleep. Is there any ways that the Progress Bar visually updates live rather than just sitting at 0% and jumping to 100% when the execution is over?
private Client getConnectionPDU()
{
// Client à retourné
PrimS.Telnet.Client client = null;
// Ouverture de la connection
try
{
// --- Ouverture de la connexion
client = new Client(rackToIP[selectedRack], addrPort, new System.Threading.CancellationToken());
console.Text += client.Read();
Thread.Sleep(sleep);
progressBar.Value = 20;
// --- Username
client.WriteLine(username + enter);
Thread.Sleep(sleep);
progressBar.Value = 40;
console.Text += "\n" + client.Read();
Thread.Sleep(sleep);
progressBar.Value = 60;
// --- Password
client.WriteLine(password + enter);
Thread.Sleep(sleep);
progressBar.Value = 80;
console.Text += "\n" + client.Read();
Thread.Sleep(sleep);
progressBar.Value = 100;
}
catch (Exception e)
{
console.Text += "\n" + e.Message;
client = null;
}
// Scroll to end
scroller.ScrollToEnd();
return client;
}