Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl TK threads using while

by sundialsvc4 (Abbot)
on Feb 06, 2012 at 14:13 UTC ( [id://952089]=note: print w/replies, xml ) Need Help??


in reply to Perl TK threads using while

First of all, I did not closely read your code.   But I did pick up on the word, “thread.”   You do not need, say, “21 threads” to do this ... or even two.   You simply need a timer, along with a way of tracking the status of each of those 21 accounts as of the last time the timer ran.   On each timer-pop, the (main) program, or as the case may be a single background thread that does nothing else, does whatever it needs to do for everyone in turn.

Replies are listed 'Best First'.
Re^2: Perl TK threads using while
by zentara (Archbishop) on Feb 06, 2012 at 17:11 UTC
    You do not need, say, “21 threads” to do this ... or even two.

    He is better off putting the socket codes into threads. If he just uses Tk's fileevent, (which is basically just select), he would be time slicing 21 sockets with a single fileevent. If one socket has a big upload, it will block all the other sockets until it is done. Having separate threads is very important here.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      Hi zentara

      Thanks for your response. The examples which you have mentioned starts automatically, but i want to start the event after pressing the button same for stop.

      If i assigned to the button it gets hangged.

      And every 3 seconds i want to display the status of process like Download in Process, Watching the Folder, No file found/ if found, Process started for file no.1/ Copying the file to server, sending e-mail. So that user will know there is some processing happning in tool.

      Any help will be much appreciated

      Thanks in Advance.

        And every 3 seconds i want to display the status of process like Download in Process, Watching the Folder, No file found/ if found, Process started for file no.1/ Copying the file to server, sending e-mail.

        Thats a pretty big request considering the code you posted. It would take me all day to properly write and test such a script. This is not a script writing service.

        My advice, is to break your program down into smaller parts, and get each working separately, then work on combining them. If you want to do something every 3 seconds, use a timer.

        use Tk; my $timer = $mw->repeat( 3000, \&my_sub);

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://952089]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-16 05:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found