On Aug 21, 2006, at 7:26 PM, Phil M wrote:

I have a thread which I would like to run in an Infinite Loop, but I want to use it more like a Timer. The reason why I am not using a time is because this thread will be used to update the GUI and I don't want actions such as accessing Menu and MouseDown events to interrupt the drawing.

So what I am using is the Thread.Sleep() method with the code below:

  While True
    // do my thing
    Me.Sleep(40)   // refresh for every 1/25 of a second
  Wend

But I have SERIOUS issue: no matter the Sleep() value, the CPU is always pegged at 100%, making my PowerBook very hot to the touch. This includes values such as 10,000 which is the equivalent to once every 10 seconds.

Is the Sleep() method seriously screwed up, or am I using it incorrectly?


I think you're using it incorrectly. The better practice for thread + GUI is to use a timer to periodically have the GUI ask the thread for current information. Jon Johnson has a good explanation of this somewhere on his nilobject.com site.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to