[Gambas-user] Problem with event parameters...

daniel danielcampos at ...277...
Thu Oct 2 23:34:00 CEST 2003


Hi all
> 
> I think there is a problem with the CPU charge. I've the same problem with my 
> bomberman, gambas use all (or near) the cpu time.
> 
> Is that normal ?
> 
> Fabien



It is normal in any language (Gambas, VB, even C or C++) :

Event loop --> large proccess --> next event loop

   (CPU 0%)       (CPU 100%)        (CPU 0%)

You can "emulate" this effect using Visual Basic:


Public sub Do_Anything()

	Do While (True)
	Loop
End Sub

If you compile and execute this code using VB, you can
see a 100% of CPU usage, even, in some cases, other
tasks that needs to scan some resources like RS-232,
can fail due to this silly program.

 The first solution (in VB) seems to be:

Public sub Do_Anythig()
	
	Do While (True)
		DoEvents	
	Loop

End Sub

 But it really does not work!

 The solution in use is:

Public sub Do_Anythig()
	
	Do While (True)
		Sleep(1)  ' Calling to API
		DoEvents	
	Loop

End Sub 


In Gambas you can use a similar way : use Wait(1) which sleeps
proccess for a milisecond, so CPU usage will be near of zero!

This problem is matter of Operating System, not Gambas...


Regards,

Daniel Campos






El jue, 02-10-2003 a las 21:04, Fabien BODARD escribió:
> Le Dimanche 28 Septembre 2003 22:36, Marco Bauer a écrit :
> > Hi Fabien,
> >
> > I originally wrote this program under gambas 0.65a and since then (gambas
> > 0.70a) the handling of mouse-events has changed (I don't know if I
> > mentioned it in my first mail concerning gcollider, but you can rotate the
> > view by pressing the left mouse button in the main window and move it
> > around). Attached to this mail you find the tar-ball for the changed
> > gcollider source which should work under gambas 0.70a -- it certanly worked
> > for me.
> >
> > Have fun.
> > Marco
> >
> > Am Sonntag, 28. September 2003 22:06 schrieb Fabien BODARD:
> > > Hi Benoit
> > >
> > > I've trying to test the gcollider, it's really pretty and work fine with
> > > gambas-0.65a... but no with gambas-0.70a... a BUG in gambas ?... benoit?
> > >
> > > gambas say for all event :
> > >
> > > too many parameter.. so i try to use the event menu in editing form to
> > > see what it put in the editor for key_press :
> > >
> > > Form_MouseMove() and not Form_MouseMove(X AS Integer, Y AS Integer,
> > > Button AS Integer)
> > >
> > > I think there is a little big problem here no ?
> > >
> > > ;-)
> > >
> > > ++
> 

> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list