New topic: 

Speed of Thread

<http://forums.realsoftware.com/viewtopic.php?t=43988>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        Don76          Post subject: Speed of ThreadPosted: Sun May 13, 
2012 3:48 pm                         
Joined: Thu May 03, 2012 3:21 pm
Posts: 3
Location: Switzerland                My thread has this code:
dim LoopSpeed = 100 '(ms)
dim UDPThreadRequestStop as boolean
Dim Now as double
dim TimeCounter as Uint32
UDPThreadRequestStop = false
Now = Microseconds
do until UDPThreadRequestStop =true
  app.doevents
  MainSemaphore.Signal
  if Microseconds-Now >= (LoopSpeed * 1000) then
  Now = Microseconds
  'Code to execute every 100ms
  if Timecounter >= 10000 then UDPThreadRequestStop = true 'Exit Loop
  'Other code....... executed in 8 ms
  TimeCounter = TimeCounter + LoopSpeed
  end if
  MainSemaphore.release
loop


The thread ends after 100 loops (100ms * 100 = 10000ms) but it ends only after 
11 or 12 seconds (not 10 seconds).
If I remove the code "app.doevents", the thread works perfectly but the CPU 
Usage is 30%.

There is a solution to this problem?
Why does "app.doevents" need a lot of CPU time? 

Note: The project contains only a thread and a window.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to