Hey Guys,

As I mentioned in a previous post I was trying to build this script and accompanying scripts/resources
into standalone executable file for Windows. I'm using the CavaPackager program in order to do this,
which also comes with a "Utility" Module called Cava::Packager which contains a bunch of methods you
can use along with your program.

For instance, all image files in my script are called "resources" by CavaPackager and you can set their
location with one of the methods in order for the program to include your virtual path to access these
files later. Well, there is also a method/function you use to execute scripts called from within other
scripts in your CavaPackager's "project".

And, for some reason if I use this Method/Function inside the Proc::Background function, it seems to work.
Even after I built the scripts into executables... The function is called "Cava::Packager::GetScriptCommand".

Here is my working code:
my $TIMEOUT = 30; my $proc; # This script is located in same dir as the calling script. my $bg_script = "bg_script.pl"; ......code..... ............... $proc = Proc::Background->new(Cava::Packager::GetScriptCommand( "$bg_s +cript", [], $ARG1, "$ARG2", $ARG3)); my $PID = $proc->pid; my $start_time = $proc->start_time; my $alive = $proc->alive; while($alive ne 0) { # This Checks again if it's still running... $alive = $proc->alive; # This while loop will force Perl::Gtk2 to continue processing # GUI Events while Background process continues executing... while (Gtk2->events_pending) { Gtk2->main_iteration; } Gtk2::Gdk->flush; $timeout_current = time; #->Sets the current time (EPOCH) # Get the difference in time from the current time and the # start time, to check if we hit the TIMEOUT limit of 30 sec $timeout_diff = $timeout_current - $timeout_start; # If the time difference is >= the TIMEOUT limit of 30 sec, then # use 'last' to break out of the loop... if ($timeout_diff >= $TIMEOUT) { $timed_out = 1; last; } # Sleep for 1000 milliseconds usleep(1000); }

So it seems that I am able to use Proc::Background after all...!

I just wanted to thank everyone for their replies, much appreciated!


Thanks Again,
Matt


In reply to Re: Using Proc::Background and Win32 by mmartin
in thread Using Proc::Background and Win32 by mmartin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.