It is currently Thu May 23, 2013 1:56 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: progress without thread?
PostPosted: Mon Aug 08, 2011 10:48 am 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
Is there a way to force an update to a progress bar without it being in a thread?

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: progress without thread?
PostPosted: Mon Aug 08, 2011 11:28 am 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1085
Location: Netherlands
Maybe you could do it inside the event loop
Code:
If OpenWindow(0, 0, 0, 320, 160, "ProgressBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ProgressBarGadget(0,  10, 30, 250,  30, 0, 100)
  t = ElapsedMilliseconds()
  Repeat
    Event = WaitWindowEvent(200)
    p = (ElapsedMilliseconds() - t) / 100
    If p > 100
      p = 100
    EndIf
    SetGadgetState(0, p)
  Until Event = #PB_Event_CloseWindow
EndIf


Top
 Profile  
 
 Post subject: Re: progress without thread?
PostPosted: Mon Aug 08, 2011 5:35 pm 
Offline
PureBasic Bullfrog
PureBasic Bullfrog
User avatar

Joined: Wed Jul 06, 2005 5:42 am
Posts: 6465
You can use AddWindowTimer and when you get a timer event check your status and update it.

_________________
Veni, vidi, vici.


Top
 Profile  
 
 Post subject: Re: progress without thread?
PostPosted: Mon Aug 08, 2011 8:42 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 531
Location: sweden
You need at least one thread ;-)
(smartass ain't I?)

I actually usually do the progressbar in the main thread (which is still a thread) and then do all the datastuff in the secondary thread.
My secondary thread does return a maxvalue.l and a nowvalue.l so I know how to draw the progressbar in the main thread.... the mainthread on the other hand focus on
repeat
if waitwindowevent(100)=#pb_event_closewindow
end
endif
;draw progressbar
until done.b


Top
 Profile  
 
 Post subject: Re: progress without thread?
PostPosted: Mon Aug 08, 2011 9:23 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
I actually got it without using a thread. Pretty simple too.

Code:
For blah blah blah To blah blah blah
 
 If ...
 ;more code here
 EndIf ...

 SetGadgetState(21, GetGadgetState(21) + Progress)
 WaitWindowEvent(1)

Next


Thanks for the help though guys! ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye