in reply to Perl::Tk - Event sequencing question

I see two possible ways:

Create your processing chain as follows:

  1. Produce list of all items to be processed
  2. Fire an event PROCESS_ONE_ITEM to yourself
  3. On PROCESS_ONE_ITEM do:
    1. Process that one item.
    2. Fire an event ITEM_PROCESSED to yourself
  4. On ITEM_PROCESSED do:
    1. update your status
    2. Fire an event PROCESS_ONE_ITEM to yourself, if there are more items in the queue

That way, you will process all items as long as there are items in the queue. The ugly part of this (and all event oriented processing) is, that all program flow logic gets moved to the events instead of the sequential ordering in the source code.

The other way is to simply spawn a "worker" Perl script that produces the "right" output by procedurally processing the list of items and interfacing to that single process from Tk via the one single Fileevent. This way has the advantage of having the program flow in a nice procedural way, and the disadvantage that you can't display nice progress unless you parse the output of your other program.

  • Comment on Re: Perl::Tk - Event sequencing question