Click here to Skip to main content
15,794,593 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How I can add delay between execution of two lines means i want to execute one line and then wait for 5 second and then execute second line. thread.sleep is not working well in windows form in c#. Is any other way?

What I have tried:

steps[recursiveStep, left].BackColor = Color.Fuchsia;
                    steps[recursiveStep, left].BackColor = Color.Green;
Updated 17-Dec-16 12:43pm

1 solution

It's complicated, because you are trying to get one thread to do o different things at the same time: show what is going on, and wait for a specific product of time before doing something else - and that isn't going to work.
So set up a Timer, and user that to kick off the second colour change instead of trying to stop the current thread, because of you stop the thread, you can't see any changes...
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900