Sleep not working right?
-
I'm having a problem that has me a bit confused. Maybe somebody out there can help me a bit. I am making an adventure type fighting game and am using a listbox to display the combat results. My combat routine is contained within a function that calculates inititive, hitting, damage and whatnot. Right now all the info gets displayed all in one shot. What I want is to add a delay between the initiative and attacking messages. What I've tried is a simple for next loop, but for some reason this has no effect. So I tried the 'System.Threading.Thread.Sleep(2000)'method and this seems to create a pause. However it seems to run at the beginning of the function even though I put it halfway into my function. Why is the .sleep method getting run first? Hopefully this makes sense. thanks.
-
I'm having a problem that has me a bit confused. Maybe somebody out there can help me a bit. I am making an adventure type fighting game and am using a listbox to display the combat results. My combat routine is contained within a function that calculates inititive, hitting, damage and whatnot. Right now all the info gets displayed all in one shot. What I want is to add a delay between the initiative and attacking messages. What I've tried is a simple for next loop, but for some reason this has no effect. So I tried the 'System.Threading.Thread.Sleep(2000)'method and this seems to create a pause. However it seems to run at the beginning of the function even though I put it halfway into my function. Why is the .sleep method getting run first? Hopefully this makes sense. thanks.
This is happening because your thread gets puts to sleep before your window has a chance to update. What you need to do is put an 'Application.DoEvents()' just before the Sleep statement and that should take care of it. RageInTheMachine9532
-
This is happening because your thread gets puts to sleep before your window has a chance to update. What you need to do is put an 'Application.DoEvents()' just before the Sleep statement and that should take care of it. RageInTheMachine9532