C#C
C#4y ago
Whiteboy

Thread.Sleep(int32) not working? Send Help [Answered]

private void BtnUpgrade_Click(object sender, EventArgs e)
        {
            if (IsEqScroll == false && IsEqAmulet == false)
            {
                var random = new Random();
                var num = random.Next(1, 1000);
                if(num < 1000/(1+ SharedClass.UpgradeLvlValue.UpgradeLevel*1.69))
                {
                    lbUpgradeOutput.BackColor = Color.FromArgb(46, 51, 73);
                    Thread.Sleep(250);
                    SharedClass.UpgradeLvlValue.UpgradeLevel++;
                    lbUpgradeOutput.Text = "Upgrade succeed";
                    lbUpgradeOutput.BackColor = Color.Green;
                    UpgradeLvl.Text = "+ " + SharedClass.UpgradeLvlValue.UpgradeLevel.ToString();
                }
                else
                {
                    lbUpgradeOutput.BackColor = Color.FromArgb(46, 51, 73);
                    Thread.Sleep(250);
                    lbUpgradeOutput.Text = "Upgrade failed";
                    lbUpgradeOutput.BackColor = Color.Red;
                }
            }
        }


So it goes like this
  • the basic color
  • 1st click on the button assigned - color goes green (succeeded)
  • 2nd click - color stays green (success again) When it should flash for 0.25 to the basic color then go green
I want to make something aka flashy event for the label with text "upgrade succeeded/failed" so when you get 2x upgrade in a row you get that little visual information that it actually tried the upgrading instead of the color being green all time

What am i missing?
Was this page helpful?