List Info

Thread: Re: problem with Gauge on windows xp...




Re: problem with Gauge on windows xp...
country flaguser name
United Kingdom
2008-02-28 04:35:51
Tim Ferrell wrote:
> The code snippet I provided did not give enough context
... that snippet 
> is called in a loop and I use Thread#join to have the
loop wait until 
> that thread finishes before proceeding to the next item
to process... I 
> would need to do some kind of polling of thread status
otherwise and 
> that just seemed cleaner...
>   
This is from the pickaxe documentation of Thread.join:

"The calling thread will suspend execution and run
/thr/. Does not 
return until /thr/ exits. Any threads not joined will be
killed when the 
main program exits."

I don't think this is what you want - i.e. to suspend
execution of the 
GUI thread while the download runs. If you want the GUI to
keep 
updating, polling is the way to go. It needn't be
complicated.

In your case it could be a simple as something like this,
assuming the 
download is in a thread saved as download_thread

Wx::Timer.every(100) do
   if not download_thread.status # false = finished normally,
nil = 
finished with exception
     download_thread = start_next_job
   end
end

Using Wx::Timer is probably preferable to sleep in your
circumstance as 
it will give more reliable timings.
>  I commented them out in turn and discovered 
> that it is the Frame#fit method that is causing the
painting weirdness. 
> Any ideas what could be causing that? Is my usage of it
proper?
>   
Looks OK to me. I guess it's just because calling fit causes
a repaint, 
which isn't otherwise visible. Hopefully using the threads
right will 
resolve this

hth
alex

_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

Re: problem with Gauge on windows xp...
country flaguser name
Germany
2008-02-28 10:18:51
Alex Fenton wrote:

> Looks OK to me. I guess it's just because calling fit
causes a repaint,
> which isn't otherwise visible. Hopefully using the
threads right will
> resolve this
> 

Hey Alex -

I tried your suggestion, removing Thread#join in favor of a
polling 
loop... and I still see the same odd painting errors on XP
and the GUI 
remains unresponsive to user interaction (no matter how hard
I click 
*grin*)...

Maybe I'm just not understanding this clearly... as I see it
there are 3 
threads involved here: the main program thread, the gui
thread spawned 
by Wx::App.main_loop, and the thread I am spawning to wrap
the open-uri 
call... I think I have a handle on having them all pass off
to each 
other and the app works fine on my mac and on Ubuntu - in
both my test 
app and the full program I only see the painting problems
and 
unresponsiveness under Windows...

Could this be the result of some bug in wxWidgets? What
version is 
bundled with the wxRuby gem? If it would help I'd be happy
to try and 
set up a debuggable environment here ... I assume I'd need
VC6 to 
compile since that is what the One-Click installer uses  but
are there 
any special steps I'd need to take with wxMSW and wxRuby? Is
there, 
perhaps, a guide to setting up all of this from source?

In any case, thanks much to you and Mario both for your help
and 
suggestions thus far 

Cheers,
Tim
-- 
Posted via http://www.ruby-forum.com
/.
_______________________________________________
wxruby-users mailing list
wxruby-usersrubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )