Progressbar while file/folder copy in progress

I would like to have a progress bar for my application while file/folder
copy is in progress. Is it possible to use “FileUtils.cp_r” in
background. So that it create different process and i can loop it to
compare initial & current size for incremental integer value. The work
flow i am expecting is as follows:-

initial_file_size
create_copy_process_bg (copy)
while copy exist
check_current_file_size
calculate_presentage_value
#use persentage integer value to set progressbar on gui.
end

What i find it difficult is to run “FileUtils.cp_r” as different process
in background.

Subject: Progressbar while file/folder copy in progress.
Date: lun 22 apr 13 10:08:40 +0900

Quoting sundar sundar ([email protected]):

What i find it difficult is to run “FileUtils.cp_r” as different process
in background.

There are several ways to obtain the result that you are trying to
obtain, but they basically belong to two categories:

  • either you run two separate processes, and you use one of the
    available methods of inter-process communications to let one process
    know information from the other process,

  • or you run two threads within the same process: threads share the
    memory space, so one thread can access data generated by the other.

The wording of your question shows that you do not have much
experience on this. If you want to learn, you must be ready to spend
some time studying and experimenting. Concurrent programming can
be unexpectedly complex.

The second method may be a bit easier to tackle, at the beginning. I
suggest that you read carefully the help page for Ruby threads. You
obtain it by typing:

ri Thread

from your command prompt. The first method can be obtained in Ruby,
for example, by using DRb, which also has a long and informative help
page:

ri DRb

Carlo