Multithreading

hi

I do a lot of inserts (duration about 3 min) and would like to show a
progressbar for the user during this inserts. I tried out to do it with
threads, but without a success. Also forking a process doesn’t work
(Windows XP). Somebody has an idea?

thanks in advance
masu

example:

this is my loading function

def load_data
Thread.new do
load_data_into_another_db …
end
end

this is a ajax function, which is called periodically

def ajax_update_progress_bar
Thread.new do
render :text => Time.now.to_s
end
end

On 4/2/07, masu [email protected] wrote:

hi

I do a lot of inserts (duration about 3 min) and would like to show a
progressbar for the user during this inserts. I tried out to do it with
threads, but without a success. Also forking a process doesn’t work
(Windows XP). Somebody has an idea?

http://backgroundrb.rubyforge.org/


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

I do a lot of inserts (duration about 3 min) and would like to show a
progressbar for the user during this inserts. I tried out to do it with threads, but without a success. Also forking a process doesn’t work (Windows XP). Somebody has an idea?

I had to do something similar recently. You can exec “start whatever” in
windows and it will start a new process with the command line you
provide (rake or ruby script/runner for example). The option /B will
even hide the window for the new process.

Regarding to the communication back to the user, I did it by creating a
“semaphore” file at launching time and deleting it at completion.
Meanwhile I had a small ajax magic querying every n seconds back to the
server and just checking if the semaphore was still alive. I was also
showing a timestamp back to the users so they could know everything was
peachy on the server side.

I know more solid solutions like Drb are available and recommended, but
this one doesn’t need any installation/monitoring and it works fine for
simple tasks.

regards,

javier ramirez

Estamos de estreno… si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!

thanks for your replies. I’m going to try it out the exec thing.

by
masu