Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I have a couple of examples that might help explain where I'm at and where I need to get to.

The two examples, attached to this e-mail, represent the development path of the tool I created.

Script "threadTest2.pl" provides the results in the same fashion as your stock ticker. This is easy to send the new information to the user's browser.

Script "threadTest3.pl" displays the items as a group every time an item changes. I can send these groups to the screen with no problem.

What I want to do is find a way to redraw the screen each time a new group is sent to the browser, so it would appear that only the status of the items is changing.

My first thought was to refresh also, but since this is a live program, that is not an option since it would restart the program.

The eventual goal is to put a cancel button below the displayed group that the user could press if the process is taking to long. The program would then cancel all threads that have not completed and continue to process and display the results from the finished threads.

Any thoughts, help or advice would greatly be appreciated.

Thanks,

Doug

### Program: threadTest2.pl ### use threads; use threads::shared; use CGI::Push qw/:standard/; # Shared variables my $progressThread1 : shared = 0; my $progressThread2 : shared = 0; my $progressThread3 : shared = 0; my $progressThread4 : shared = 0; my $progressThread5 : shared = 0; # Arrary of progress text @progress = ( 'No Activity....', 'Connecting.....', 'Searching......', 'Parsing........', 'Finished.......', 'Error..........', ); # Create threads $thr1 = threads->new(\&thread1); $thr2 = threads->new(\&thread2); $thr3 = threads->new(\&thread3); $thr4 = threads->new(\&thread4); $thr5 = threads->new(\&thread5); # Do not end program until all threads have finished $thr1->join(); $thr2->join(); $thr3->join(); $thr4->join(); $thr5->join(); sub thread1 { sleep 6; screenDisplay( 1, 1 ); sleep 2; screenDisplay( 1, 2 ); sleep 4; screenDisplay( 1, 3 ); sleep 5; screenDisplay( 1, 4 ); } sub thread2 { sleep 8; screenDisplay( 2, 1); sleep 2; screenDisplay( 2, 2 ); sleep 4; screenDisplay( 2, 3 ); sleep 5; screenDisplay( 2, 4 ); } sub thread3 { sleep 3; screenDisplay( 3, 1 ); sleep 2; screenDisplay( 3, 2 ); sleep 4; screenDisplay( 3, 3 ); sleep 5; screenDisplay( 3, 4 ); } sub thread4 { sleep 10; screenDisplay( 4, 1 ); sleep 2; screenDisplay( 4, 2 ); sleep 4; screenDisplay( 4, 3 ); sleep 5; screenDisplay( 4, 4 ); } sub thread5 { sleep 1; screenDisplay( 5, 1 ); sleep 2; screenDisplay( 5, 2 ); sleep 4; screenDisplay( 5, 3 ); sleep 5; screenDisplay( 5, 4 ); } sub screenDisplay { my ( $thread, $status ) = @_; print $progress[$status], "Thread: $thread\n"; return undef; } ### Program: threadTest3.pl ### use threads; use threads::shared; use CGI::Push qw/:standard/; # Shared variables my $progressThread1 : shared = 0; my $progressThread2 : shared = 0; my $progressThread3 : shared = 0; my $progressThread4 : shared = 0; my $progressThread5 : shared = 0; # Arrary of site names @sites = ( '', 'Site One', 'Site Two', 'Site Three', 'Site Four', 'Site Five', ); # Arrary of progress text @progress = ( 'No Activity....', 'Connecting.....', 'Searching......', 'Parsing........', 'Finished.......', 'Error..........', ); # Create threads $thr1 = threads->new(\&thread1); $thr2 = threads->new(\&thread2); $thr3 = threads->new(\&thread3); $thr4 = threads->new(\&thread4); $thr5 = threads->new(\&thread5); # Do not end program until all threads have finished $thr1->join(); $thr2->join(); $thr3->join(); $thr4->join(); $thr5->join(); sub thread1 { sleep 6; $progressThread1 = 1; screenDisplay(); sleep 2; $progressThread1 = 2; screenDisplay(); sleep 4; $progressThread1 = 3; screenDisplay(); sleep 5; $progressThread1 = 4; screenDisplay(); } sub thread2 { sleep 8; $progressThread2 = 1; screenDisplay(); sleep 2; $progressThread2 = 2; screenDisplay(); sleep 4; $progressThread2 = 3; screenDisplay(); sleep 5; $progressThread2 = 4; screenDisplay(); } sub thread3 { sleep 3; $progressThread3 = 1; screenDisplay(); sleep 2; $progressThread3 = 2; screenDisplay(); sleep 4; $progressThread3 = 3; screenDisplay(); sleep 5; $progressThread3 = 4; screenDisplay(); } sub thread4 { sleep 10; $progressThread4 = 1; screenDisplay(); sleep 2; $progressThread4 = 2; screenDisplay(); sleep 4; $progressThread4 = 3; screenDisplay(); sleep 5; $progressThread4 = 4; screenDisplay(); } sub thread5 { sleep 1; $progressThread5 = 1; screenDisplay(); sleep 2; $progressThread5 = 2; screenDisplay(); sleep 4; $progressThread5 = 3; screenDisplay(); sleep 5; $progressThread5 = 4; screenDisplay(); } sub screenDisplay { print $progress[$progressThread1], $sites[1], "\n"; print $progress[$progressThread2], $sites[2], "\n"; print $progress[$progressThread3], $sites[3], "\n"; print $progress[$progressThread4], $sites[4], "\n"; print $progress[$progressThread5], $sites[5], "\n\n"; }

20030926 Edit by Corion: Fixed formatting


In reply to Re: HTML Display by Gwalchmai
in thread HTML Display by Gwalchmai

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (7)
As of 2024-04-23 13:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found