CreateTimer(1000) vs CreateTimer(1001)
BlitzPlus Forums/BlitzPlus Programming/CreateTimer(1000) vs CreateTimer(1001)
| ||
Is anyone else seeing this strange behavior in Blitz+? The following code seems to ignore the timer entirely. window=CreateWindow("WHOOPS",0,0,100,100) canvas=CreateCanvas(0,0,100,100,window) SetBuffer CanvasBuffer(canvas) timer=CreateTimer(1000) Repeat Cls Text 0,0,MilliSecs() FlipCanvas canvas WaitTimer(timer) Until KeyDown(1) However, if you change the 1000 to 1001, the program freezes. Can anyone duplicate this? |
| ||
Is that a no? |
| ||
Same odd behaviour here. |
| ||
I guess this means that one millisecond is the smallest measurable time interval. CreateTimer(1000) makes the interval exactly 1/1000 of a second. This is the smallest possible 'clock tick'. |
| ||
weird city |
| ||
So why does it freeze with 1001? |
| ||
In my opinion this looks like a bug. It should not freeze like that. In addition, I ran IDIOT's code (1001 part) and it froze up. Any other code I ran after this that used wait timer seem to lock up as well even though it was well below 1001 , in my case 30. If you have not already, post this in the B+ bug section. Your likely to get the obligatory "don't use a timer over 1000" comment, but B+ should be solid enough to not lock-up if you were to use 1001+. BTW... Nice to see you around IDIOT! :) L8r, |
| ||
I have had some strange stuff with createtimer. If my memory serves me correctly I was even experiencing lock-up. I ended up having to use... z=targetspeed-(MilliSecs()-loopspeed) If z>0 Then Delay z loopspeed=MilliSecs() ...instead. |
| ||
There are other issues with WaitTimer() I know Mark is aware of, but this seems new. :) L8r, |
| ||
Well, I found it trying to get around another problem. I'm writing an updated pixel ruler program using the borderless window feature (which is really cool BTW). But it's spiking the CPU with like 90%+ usage, and I'm trying to decrease that as much as possible (or at all really). I can't use waitevent() because I constantly have to draw a line where the mouse is. I was hoping having a slow timer would do something, but it doesn't, and there's that bug. Any ideas? |
| ||
Dont know if this will help but it sounds like just what your looking for: [a ftp://user:blitz@eikon.myftp.org/eiksoft/ruler.txt]ftp://user:blitz@... [/a] Low cpu usage too. |
| ||
Neat! Not exactly what I was making, but it has the exact same name! |
| ||
Thanks. If your ruler goes big (huh huh) I will humbly change mine ;) |
| ||
Haha, don't worry about it. I need to stop naming all my Blitz+ projects Something+. And it's not going anywhere if I can't get the CPU usage down. Why is there no way to set the process priority in Blitz? I've seen other programs that let you change their priority, I wish you could set it for your Blitz programs. |
| ||
Well Idiot it might be possible with the following api: SetThreadPriority SetPriorityClass but im no good with userlibs. |
| ||
@Idiot I'm having the same CPU throttle problem for screen savers and my media player. This is a problem I'm sure Mark is aware of but needs to address. :) L8r, |
| ||
Using the Delay command in your game loop frees up CPU usage. |
| ||
I would prefer thread control or even slice control. :) L8r, |
| ||
I think using waitevent(10) or such will do what I want, I think I was confused about that in the same way I was confused about waittimer()... smaller number=longer wait. |