Hi Alex,
Thank you so much for taking time to give me the guidance!
I’ll try your suggestion and remove the threads and see what happens …
Thanks again!
----- Original Message ----
From: Alex F. [email protected]
To: General discussion of wxRuby [email protected]
Sent: Wednesday, February 20, 2008 5:35:41 PM
Subject: Re: [wxruby-users] hang on leopard
Zhang
Peng
wrote:
If
it
is
a
thread
issue,
I
wonder
why
I
couldn’t
duplicate
it
on
XP?
Since
I
can’t
duplicate
it
on
XP,
I
was
thinking
that
it
is
not
just
a
pure
thread
issue,
but
Wx
for
OSX
+
ruby
thread
combination
is
the
culprit.
Because
wxRuby
/
wxWidgets
uses
different
native
platform
functions
internally,
there’s
no
guarantee
that
if
you’re
doing
something
wrong,
it
will
fail
in
the
same
way,
or
at
all,
on
different
platforms.
But
it
should
always
work
if
done
right
…
Thanks
for
offering
help
on
design
choice.
I
appreciate
it
!
I
don’t
actually
have
a
lot
of
globals
and
threads
…
only
2
globals
and
3
threads.
Let
me
try
to
explain:
I
have
one
dialog
box
that
shows
a
number
flashing
on
the
screen
one
after
another,
and
another
dialog
box
that
shows
the
time
and
a
input
text
field
to
collect
the
answer
the
user
types
in
for
adding
up
all
those
numbers
from
the
other
dialog.
OK.
First
of
all,
I
really
don’t
think
you
need
to
use
threads
or
globals
at
all
to
achieve
this.
wxRuby
like
other
GUI
packages
is
essentially
event
driven:
updates
to
the
GUI
should
be
driven
by
events.
This
includes
user
interaction
(clicking
a
button)
or
timed
events
(a
timer
ticks).
So,
I
have
2
global
variables:
one
for
each
instance
of
the
dialog
box.
I
use
global
because
I
do
not
want
to
destroy
and
create
a
new
instance
of
the
dialog
box
every
time
a
user
want
to
do
the
exercise.
Fair
enough.
You
could
make
them
instance
variables
of
your
Wx::App
class,
create
them
when
the
app
starts,
and
provide
an
accessor
to
them.
Then
you
could
access
them
anywhere
in
your
code
with
Wx::THE_APP.number_dialog
etc.
I
have
3
threads:
one
to
show
the
flashing
number,
one
to
collect
answer,
and
one
for
showing
the
time.
I
use
WxTimer.every()
for
the
timer
per
your
suggestion.
I
use
ruby
thread
for
the
other
2
as
you
see
in
the
code
I
posted
yesterday.
I
was
suggesting
you
use
Wx::Timer
in
place
of
threads.
A
timer
to
update
the
status
bar
with
the
current
time
doesn’t
need
to
be
much
more
complicated
than:
Wx::Timer.every(1000)
{
self.status_text
Time.now.to_s
}
No
threads
needed…
So,
when
user
hit
the
button,
both
ruby
threads
will
start/resume
their
tasks:
one
to
show
the
number
and
one
to
collect
the
answer,
and
WxTimer
shows
the
time.
You
can
catch
when
the
button
is
clicked
with
evt_button,
and
then
just
call
a
method
on
the
other
dialog
to
tell
it
to
stop
displaying
numbers.
Again,
I’m
sure
you
don’t
need
threads
here.
Finally,
you
can
catch
when
characters
are
entered
in
a
TextCtrl
using
evt_text.
Or,
if
you
want
to
monitor
the
TextCtrl’s
contents
continually,
again,
just
use
a
Timer
and
call
text_ctrl.value.
If
you
need
to
stop
and
start
Timed
actions,
you
can
capture
the
return
value
of
Wx::Timer.every
and
call
stop
on
it:
@number_timer
Wx::Timer.every(2500)
do
display_number
call
code
to
display
a
new
number
on
the
screen
end
@number_timer.stop
Stop
the
timer
ticking
@number_timer.start
Restart
it
later
hth
alex
wxruby-users
mailing
list
[email protected]
http://rubyforge.org/mailman/listinfo/wxruby-users
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ