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.
4828d528e2e46f7c8160c336eb332836?d=identicon&s=25 Robert Heiler (shevegen)
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.
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2015-08-04 18:22
Robert Heiler 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.
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2015-08-05 13:20
Regis d'Aubarede wrote in post #1177247:
> Robert Heiler 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.