in reply to Re^6: Spinning cursor while waiting for search/copy process to be finished
in thread Spinning cursor while waiting for search/copy process to be finished
You can fork a new process and make it run the spinner, or create a thread running a spinning function. Link to an example solution was posted in Re: Spinning cursor while waiting for search/copy process to be finished.
Forking spinner can be easier to write, but it must be noted that you may have problems killing the spinner process on platforms not supporting fork syscall natively (win32, for example). Search safe signals win32 for more information. Update: child is not blocked in writing operation continiousely, so signals should not be a problem.
my $j = 0; if ((my $pid = fork()) == 0) { # this runs in child process do {sleep 0.5; spin($j)} while 1; # normally we should put some kind of exit statement here, but the lo +op above is infinite } elsif ($pid > 0) { # parent/main process ...; # put your loop here kill 1, $pid; # stop the spinner process waitpid $pid, 0; # this should help against zombies } else { # fork returned undef die "fork: $!\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Spinning cursor while waiting for search/copy process to be finished
by Ingvar (Novice) on Mar 27, 2013 at 10:52 UTC |