This code runs fine (except you can’t mess with the window until the 10
loops are finished). But if the comment mark is moved down to the
10.times
do so that it can run in a different thread, nothing below Thread.new do
ever happens. Help! please. Thanks.
I’m running Ruby 1.9.3 and wxRuby 2.01.
def busy_task
# start task in a separate thread
@text.append_text “In busy_task\n”
Thread.new do
10.times do
@text.append_text "In busy_task\n"
@tasks += 1
tasks = @tasks
10.times do
@text.append_text "running #{tasks} ... #{Time.new}\n"
(1...1_00_000).inject :+
end # do
@text.append_text "Thread #{tasks} done\n"
end # do
end # busy_task
–
I have a right and a left brain, but there is nothing right in the left
one
and there is nothing left in the right one!
Homepage: edsbog.com http://edsbog.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Ed,
On 25.11.2011 08:14, Ed Connell wrote:
This code runs fine (except you can’t mess with the window until
the 10 loops are finished). But if the comment mark is moved down
to the 10.times do so that it can run in a different thread,
nothing below Thread.new do ever happens. Help! please. Thanks.
wxRuby doesn’t like threads. Search the mailing list archives and
you’ll find plenty of topics related to your problem. If you don’t
need shared memory, I recommend you to look into processes.
Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJO0K0BAAoJELh1XLHFkqhaMEYH/07g2Qa505om9GNb4Y0ozSEn
wByEaHu/C8VD9k9dOwzudoK4uP0FJyKPR39o6TFlD6kcYNy5nrJxiIitoHmuuw+P
qXgS6qvcBub1vBHhx1WKiyb5SYaeBKDC/wXR7fdpjoql/f6vY9vOQ9iXFIMqmLMA
h4cX6yzVNyfT88Ss4hia4L/ZccL6/6TnzneN/z1h49wdfAEdlR3gZ7vTlmUpuWt0
i/4PnmBjXYL2NGEXnaRRgaXEpQB1q3Mrj4c8wC87WnM5M+1lp7N63swYW7BvZYOt
zCu19Vs1zuLftA3iUOen9JAwa9qyKJeEW1WdbFCOLuGWXagSAc2gbcBM/TrSF1k=
=x1sV
-----END PGP SIGNATURE-----