[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Best way to kill a thread started from a TkButton push

Jason Tahaney

7/18/2006 9:52:00 PM

Hello all,

Looking for the best way to kill a thread started from
a TkButton push.

I'm just using one thread that I would like to control
via a Tk Start button and a Tk Stop button.

The reason for the question is that I'm using a method
called stop_thread that takes the thread to stop as
it's argument and simply using thread.kill, and
setting my button states back to normal ; This for the
most part works except when I call it from code as
opposed to from a user event. The button states do
not go back to normal for some reason when I call
stop_thread from code.

BTW it's the tk8.3 lib on win32.

Thanks in advance,

Jason

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail...

2 Answers

John Johnson

7/19/2006 7:35:00 PM

0

Jason Tahaney wrote:
> Hello all,
>
> Looking for the best way to kill a thread started from
> a TkButton push.
>
> I'm just using one thread that I would like to control
> via a Tk Start button and a Tk Stop button.
>
> The reason for the question is that I'm using a method
> called stop_thread that takes the thread to stop as
> it's argument and simply using thread.kill, and
> setting my button states back to normal ; This for the
> most part works except when I call it from code as
> opposed to from a user event. The button states do
> not go back to normal for some reason when I call
> stop_thread from code.
>
> BTW it's the tk8.3 lib on win32.

I can't help with your problem exactly, but this sounds like it is to do
with the Binding of the variable(s).
See the Pickaxe book: http://www.rubycentral.com/book/e...

An excerpt:
"One small caution when using the code block form: the scope of
variables is not what you think it is. The block is actually evaluated
in the context of the widget's object, not the caller's. ..."

Regards,
JJ

Jason Tahaney

7/20/2006 6:19:00 PM

0

John Johnson wrote:
> Jason Tahaney wrote:
>> it's argument and simply using thread.kill, and
>> setting my button states back to normal ; This for the
>> most part works except when I call it from code as
>> opposed to from a user event. The button states do
>> not go back to normal for some reason when I call
>> stop_thread from code.
>>
>> BTW it's the tk8.3 lib on win32.
>
> I can't help with your problem exactly, but this sounds like it is to do
> with the Binding of the variable(s).
> See the Pickaxe book: http://www.rubycentral.com/book/e...
>
> An excerpt:
> "One small caution when using the code block form: the scope of
> variables is not what you think it is. The block is actually evaluated
> in the context of the widget's object, not the caller's. ..."
>
> Regards,
> JJ

Thanks, you got me thinking about the scope and it ended up being just
that, the scope awareness caution excerpt you provided from the pickaxe
book.

Regards,

Jason


--
Posted via http://www.ruby-....