Here is a version that runs just fine on Windows XP ... using threads.
use strict; use Tk; use File::Spec; use threads; use Thread::Queue; my $RequestQ = Thread::Queue->new; my $worker = threads->new(\&worker); my $top = MainWindow->new(); my $menubar = $top->Menu(-type => 'menubar'); $top->configure(-menu => $menubar); my $filemenu = $menubar->cascade(-label => '~File', -tearoff => 0); $filemenu->command(-label => '~Report extract', -command => [\&report_extract], ); $filemenu->command(-label => 'E~xit', -command => [\&Shutdown], ); print STDERR "there's a tiny window open, it's small but it's there\n" +; MainLoop(); print STDERR "Exit Main loop \n"; ############################ sub Shutdown{ $RequestQ->enqueue(undef); # quit the worker $worker->join; print STDERR "FINISHED Shutdown\n"; exit; # Clean up Tk } ############################ sub report_extract { my $tmpdir = File::Spec->tmpdir(); open (F, ">$tmpdir\\xx.csv") || die $!; print F "aaa,bbb,ccc\nddd,eee,fff\n"; close F; my $cmd = "start $tmpdir\\xx.csv"; print STDERR "running $cmd\n"; $RequestQ->enqueue($cmd); } ################## sub worker{ while (my $target = $RequestQ->dequeue){ print STDERR "Request $target Read\n"; system $target; print STDERR "Finished target\n"; } print STDERR "Thread exit\n"; }

Offense, like beauty, is in the eye of the beholder, and a fantasy.
By guaranteeing freedom of expression, the First Amendment also guarantees offense.


In reply to Re: subprocess delay on Windows with Perl/Tk by NetWallah
in thread subprocess delay on Windows with Perl/Tk by kgoess

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.