I've had some luck doing this using fork() and a pipe to communicate
between the (pseudo) processes. On Win32, fork is emulated using perl
threads. So it's basically the same thing. I haven't tested this on
Perl 5.10 yet, but I've had a gui application built this way running
and in use for more than 18 months now.
Create and layout the window before spawning a new process/thread, as
both pseudo processes can use the same gui handles. After the
thread/fork instantiate the non threadsafe modules. (Like opening a
DBI connection).
Thanks,
Charles Alderman
----- Original Message -----
From: Jeremy White <jez_white@...>
Sent: Wed, 18 Jun 2008 14:58:46 +0000
Re: Re: [perl-win32-gui-users] Avoid the appearance of a "frozen" window
>
> Hi,
>
> If you are doing the processing in a loop, you can call DoEvents
> which will unfreeze the window and process all events currently in
> the queue. This approach would only work if the call to DoEvents
> happens frequently enough while you are processing. The alternative
> approach is to use threads. As long as you are using a modern perl
> (ie, 5.8.7+) and the latest version of Win32::GUI you should have no
> problems with threads.
>
> Cheers,
>
> jez.
>
> ________________________________
> From: perlrob@...
> To: perl-win32-gui-users@...
> Date: Tue, 17 Jun 2008 21:38:50 -0600
> Subject: [perl-win32-gui-users] Avoid the appearance of a "frozen" window
>
>
> Hi
> all,
>
> I’m
> curious: how do you prevent your window from looking like it’s frozen
> during lengthy operations? For example, suppose a user clicks a button that
> will trigger a very long event, such as copying a 10 GB file. While
> the really
> long event is underway, how do you free up your window so that it doesn’t
> appear unresponsive? I usually resort to writing two separate
> programs--the GUI
> and a “worker”--and I just launch the worker when needed.
>
>
>
>
>
>
>
> I
> realize threads are an option, but in my experience they are not always
> reliable (many Win32::GUI modules don’t seem to be thread-safe).
>
>
>
>
>
>
>
> Thanks,
>
>
>
> Rob
>
>
>
>
>
>
>
>
> _________________________________________________________________
>
> http://clk.atdmt.com/UKM/go/msnnkmgl0010000007ukm/direct/01/
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>
|