Process/Thread Priority Findings

BlitzMax Forums/BlitzMax Programming/Process/Thread Priority Findings

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Ah another Delphi programmer do a bit of that myself. Real job :).

Interesting the Yahoo widget is such a CPU hog.


In delphi you hook the application idle process to do your looping. In bmax you can code that easy enough.

Bah timers you should calculate that yourself and run full speed just like your are doing now.

SuperStrict
Global F1:Int=False
Global F2:Int=False
Global F1X :Float=0
Global F2X :Float=0
Global LastTime:Int
Const PIXELSPERSEC:Float=10




Graphics 640,480
Function ProcessInput:Int()
	While PeekEvent()
		PollEvent()
	  	Select EventID()
		Case EVENT_KEYDOWN
	  		If EventData()=KEY_F1 F1= Not F1
			If EventData()=KEY_F2 F2= Not F2		
			If EventData()=KEY_ESCAPE Return False
		Case EVENT_APPTERMINATE
		  Return False
		End Select
	Wend 
	Return True
End Function

  
LastTime=MilliSecs()
While ProcessInput()
	Cls
	' move the text if on at 10 pixels per sec
	Local dt:Int
	dt=MilliSecs()-LastTime
	' if change in time since last frame
	If dt>0
		LastTime=MilliSecs()
		Local dx:Float = dt * PIXELSPERSEC/1000
		F1X:+dx
		F2X:+dx
		If F1X>640 F1X=0
		If F2X>640 F1X=0
	End If
	If F1 DrawText "F1 is on",F1X,0
	If F2 DrawText "F2 is on",F2X,10
	Flip
Wend


Hope that helps give you some ideas. Obviously you can incoporate this into a class framework. I have done a simple one that is named TApplication funny enough :)

Doug Stastny