Hi, there. I'm working with an application that is kind of like a casino and I need help. I'm looking for a code/command that can set the amount of delay before the execution of code. For example:
So, how do I make a 1-ms delay? In this example, I had setup a for loop and it will be executed about 2 times to add a number to a stored number. For example, if I had it setup like this:
for(i = 0; i < 2; i++)
// Wait about 1 millisecond before the execution of code.
// Then execute a code.
Slot 1: 2
Slot 2: 1
Slot 3: 4
Well, each slot will have a number up to a maxinum of 10. If it exceeds 10, then it will start from 0 in order to continue.
If I had Slot1 set to be delayed about 4 milliseconds, Slot2 set to be delayed at 8 milliseconds, and Slot3 set to be delayed at 16 milliseconds, then I will get this:
Slot 1: 6
Slot 2: 9
Slot 3: 9
To give you a little more understanding of what I mean, here's how it works since after every millisecond, a number that was displayed in all the slots had been added:
Slot 1: 2, 3, 4, 5, 6
Slot 2: 1, 2, 3, 4, 5, 6, 7, 8, 9
Slot 3: 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Well, I hope you get the understanding of what I mean. Plus, delay instruction can also be used for making smooth change to transparency, moving window, etc.
So, does anybody know the code for delaying an execution of instruction/code/statement?
Thanks in advance!
Use the static method Sleep from System.Threading.Thread:
int millisecond = 7;
System.Threading.Thread.Sleep( millisecond );