Forum: Ruby-Gnome 2 Threads in Ruby-Gnome?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7e17d370dc95b48cd82944a62f1caf76?d=identicon&s=25 Robert H. (Guest)
on 2015-08-03 13:00
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.
9d2d160377d47a2144b12d36ab63126f?d=identicon&s=25 Regis d. (Guest)
on 2015-08-04 18:22
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.
9d2d160377d47a2144b12d36ab63126f?d=identicon&s=25 Regis d. (Guest)
on 2015-08-05 13:20
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
This topic is locked and can not be replied to.