

However, as I said before, this is a terrible solution.

#PHP SLEEP FOR 500 MILISECONDS CODE#
Refresh will force the code to stop and redraw the screen, so that will happen before the Sleep is reached. If you call Refresh on the controls that you are changing, after changing the images but before calling Sleep, then you will see the changes. There is an easy way to fix this, but it's a terrible solution.
#PHP SLEEP FOR 500 MILISECONDS UPDATE#
In other words: With the code that you have, your screen won't update the image until after the Tick method finishes, and at no other time. In fact, the message won't be processed until after the method exits. Even at that point, the message won't be processed, though. Unfortunately, Sleep will stop messages from being processed, so the Paint message will sit there in the queue, and not be processed until after the sleep is finished. The screen will only update when that message gets processed from the message queue. When you change the images, all you are really doing is invalidating the image, which causes a Paint message to be posted. It stops the program from processing messages, and you really NEED some messages to be processed. I expect that you were thinking the screen would update during that sleep, but that's not the case. You changed some images then called Sleep. I'm pretty sure I know what you were expecting to have happen, and know why it didn't. If the sleep is on a background thread, then.not only what results were you expecting, but how do you know they didn't happen?ĮDIT: I obviously hadn't looked at your code when I wrote that. So, when you say, "with the same results", what results are you expecting? If this is on the UI thread, the results would generally be that something moderately bad happened (there is almost NEVER a right time to sleep the UI thread, though I did fine one case where I felt it was acceptable, so I won't say that there is absolutely never a right time for it). There are too many things that could get in the way of that. However, I'm not sure that you would necessarily SEE a one second pause in a background thread. Sleep is usually a bad idea, unless you are calling it on a background thread, in which case it should be fine. It's often a bit hard to know which will bite you and which will not, so leaving Option Strict ON is a good idea.

Some will never cause you any trouble, but will be ever so slightly slower than the correct code (using explicit conversions), but there are some that are hiding bugs that will bite you badly at runtime. What Option Strict ON does is prevents implicit conversions, so if you have been leaving it off, expect MANY (though simple) errors when you turn it on. Option Strict ON can be set at the project level on the Compiles tab of Project | Properties, but it would be better to go into Options and set it there such that it is on for EVERY project.
