Hi!
I followed the 'problem with Gauge on windows xp...'
discussion and I'm
having difficulties to understand the resulting code from
Alex. As my
problems are not connected to Tims problem, I start a new
one.
Please bear in mind that these are questions because I would
like to
understand the code and are not meant as a critical comment
about the
code.
Am 28 Feb 2008 um 23:31 hat Alex Fenton geschrieben:
>
>def start_job(idx)
> Thread.abort_on_exception = true
> url = "blah #"
> fname = File.basename(url)
> dialog.status_label.label = "Faking download
# of #: #"
1. Is there any advantage of writing "#"
instead of "10" here, I
don't see?
> dialog.update
> dialog.progress_all.value = (100 * (idx/10.0)).to_i
> worker = Thread.new do
> Thread.current[:progress] = 0
2. Is Thread.current not identical with self inside the
block?
3. Why do we have to define the thread-local progress here?
Without
this line it would also be defined as a thread-local
variable in the
upto-block, wouldn't be a block variable and would so
survive the block
cycles, wouldn't it?
> 1.upto(10) do | count |
> break if dialog.cancelled
> Thread.current[:progress] = (100 *
(count/10.0)).to_i
4. Why is the former dialog.update now unnecessary?
> sleep(0.1)
> end
> if dialog.cancelled
> Thread.stop
> end
5. Why not directely 'Thread.stop if dialog.cancelled' in the
upto-
block? finish exits in this case anyway. What am I
overlooking?
> end
>end
Am 28 Feb 2008 um 21:15 hat Alex Fenton geschrieben:
> def finish
> monitor.stop
> if dialog.cancelled
> dialog.hide
> md = Wx::MessageDialog.new( dialog, "You
cancelled!",
> TITLE,
>
Wx::OK|Wx::ICON_EXCLAMATION)
> md.show_modal
> code = 1
> else
> dialog.progress_all.value = 100
> dialog.hide
> md = Wx::MessageDialog.new( dialog, 'Fake download(s)
complete!',
> TITLE, Wx::OK, Wx: EFAULT_P
OSITION)
> md.show_modal
> dialog.hide
6. Why do we need ' dialog.hide' two times?
> code = 0
> end
> dialog.destroy
> exit(code)
> end
Thanks in advance if someone is willing to help me
understand.
Dirk
_______________________________________________
wxruby-users mailing list
wxruby-users rubyforge.org
ht
tp://rubyforge.org/mailman/listinfo/wxruby-users
|