visual studio 2008 - C# - Alternative to Thread.Sleep? -
I am doing all this in Visual Studio 2008 in C #.
I want to slow down the work of my algorithm so that the user can see his work, a periodic change appears on the GUI, so after each example I added "thread.sleep".
The problem is that "thread. Sleep", when set at least one second, "Thread.sleep" (after some loops) simply freezes the entire GUI and it completes the program It just keeps on going. Not now, but it is always happy how fast it depends on the length of sleep.
I have full proof that the whole program is not stable, it is working, here Until sleep is pausing the right length. But GUI few points At the point when the algorithm is finished, it shows the correct last position at that point.
How to solve this issue? Alternate to stop algorithms at some point?
First of all, do not wait for the user to work before they even think about when it will end It is useless. Please, do not just say.
Secondly, you are sleeping "UI Thread" "This is the reason that the UI thread is" locking up. "The UI thread can not be blocked; if it is, the UI thread can not update the controls on your form and the system can respond to messages. Response of system messages is an important function of the UI thread; Failure to do so causes your application to lock the system. There is no good thing.
If you want to complete it (do not do) only when you start working, then when it works, then indicates the time to stop the act of doing it.
Again, please do not do that.
Comments
Post a Comment