Threads in Ruby-Gnome?


#1

Hello.

I have a simple widget.

One button to play a video file in mplayer.

When I click on it, it freezes the gtk app. The video is played fine but
I don’t like that my program is frozen.

The code I use is this:

Thread.new {
system MPLAYER+’ '+videofile
}.join

Is there a way to not have the main app freeze? It unfreezes when the
mplayer stops.


#2

Robert H. wrote in post #1177172:

Thread.new {
system MPLAYER+’ '+videofile
}.join

Is there a way to not have the main app freeze? It unfreezes when the
mplayer stops.

suppress the .join
your code in thread must not call gtk api.


#3

Regis d’Aubarede wrote in post #1177247:

Robert H. wrote in post #1177172:

Thread.new {
system MPLAYER+’ '+videofile
}.join

Is there a way to not have the main app freeze? It unfreezes when the
mplayer stops.

suppress the .join
your code in thread must not call gtk api.

if user press 20 times the button, you will have 20 mplayers running…

you can test the number of thread running:
if Thread.last.size==1
Thread.new { system … }
else
message(“already running!”)
end