Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Tk::Repeat Question
Hi folks,

I've got a question about Tk::Repeat, I'm fairly familiar with Perl,
but it still gets a little confusing at times.  Any answers or
references to info would be greatly appreciated.  Here it goes:

$repeatid = $mw->Repeat(10, sub {...});

Inside the sub, a conditional tests for a pending queue, if it finds
one, it takes the info and passes it on to another sub to be
processed.

The code works fine, I'm just trying to figure out *how* it works.

Now the Repeat command executes the sub immediately, then once again
every 10ms, correct?

Everytime it runs, it's run as an event handler, which I assume means
it's not technically a loop, and any code after this command will
execute, interrupted every 10ms by the repeat 'event'.

I don't know if I'm on the right track or not, but I could use some
guidance.

Thanks everyone.
-jH

Report this thread to moderator Post Follow-up to this message
Old Post
jacksonh
08-28-04 08:57 PM


Re: Tk::Repeat Question
"jacksonh" <parlei@AOL.COM> wrote in message
news:9123e7e0.0408280912.4d2e5b61@posting.google.com...
> Hi folks,
>
> I've got a question about Tk::Repeat, I'm fairly familiar with Perl,
> but it still gets a little confusing at times.  Any answers or
> references to info would be greatly appreciated.  Here it goes:
>
> $repeatid = $mw->Repeat(10, sub {...});
>
> Inside the sub, a conditional tests for a pending queue, if it finds
> one, it takes the info and passes it on to another sub to be
> processed.
>
> The code works fine, I'm just trying to figure out *how* it works.
>
> Now the Repeat command executes the sub immediately, then once again
> every 10ms, correct?

No. The repeat command also waits the specified time delay to start the
first instance of the subroutine. Of course with a 10 ms delay - you would
think it starts immediately. Try making it 10000 ms and you will see that
indeed it waits 10 seconds to start the first callback.

>
> Everytime it runs, it's run as an event handler, which I assume means
> it's not technically a loop, and any code after this command will
> execute, interrupted every 10ms by the repeat 'event'.
>
> I don't know if I'm on the right track or not, but I could use some
> guidance.

I had a similar question three years ago.

[url]http://groups.google.ca/groups?selm=a4_C6.457%24D4.40786%40www.newsranger.com[/url
]

Bottom line: The repeat will start it's 10 ms countdown to the next sub
*after* the completion of the first sub. This explanation also might not be
completely true as I'm sure that it also matters when the MainLoop gets
entered in order to handle all the pending events.

With no sample code supplied it is hard to determine what happens in your
case. i.e. If you fork and use a fileevent then your subroutine will end and
a new one will begin ~10ms later - meanwhile the other "process" is still
running. If you are doing this then you could have one process reporting
back later even if it started earlier. Anyways - there are lots of
variations on the theme - so sample code would help.

Jack



Report this thread to moderator Post Follow-up to this message
Old Post
Jack D
08-29-04 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:48 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.