Re: Async processing issue within an event handler

Steve Cookson <[email protected]> Sun, 27 Sep 2015 09:27:11 -0300
Newsgroups gmane.comp.lang.perl.wxperl
Message-ID <[email protected]>
Hi James,

On 24/09/15 18:13, James Lynes wrote:
> Based on your comments I went and read the Perl Threads tutorial and 
> searched Perl Monks for Wx and Threads(very little there). Also no 
> working example on the wxPerl Wiki.
>
> I think Threads and Threads::Shared with lock() is the way to go. Now 
> I just have to go figure it out!
You'll still need wx::Timer to keep on checking the status of your threads.

Here are some snippets from my code, $gl_media_thread_hsh is a global 
variable.  I hope you can make sense of it.  If you need more detail, 
please just ask.

# import libraries
use threads ();                                        # Used for 
multi-tasking ffmpeg
use threads::shared;

# Check operation

             if ($value->is_running ne "1") {                    # Check 
status and if not executing:-
                 my $result = $gl_media_thread_hsh->{$key}->join();    
     #     - collect result.



# Post next thread

             $gl_media_thread_hsh->{$thread_no} = threads->new(
                 sub {
                     my $result = 0;
                     $result = $next_job->execute() if -e 
$next_job->{input_file};            # trigger job in background.
                     return $result;
                 }
             );
             $i_queue->post_new_job($loc_hash_count_int);        # 
Increment next available thread.

Regards

Steve.