On Thu, Oct 25, 2012 at 1:48 PM, <Amphitryon@ok.de> wrote:

My first contribution on this list is not how to run a program but
how to stop it. ;)

The typical way to stop a program that uses ooDialog is through the cancel or ok buttons and let the ok() and cancel() methods of the base class end the dialog.

Your case is complicated by the fact that you are starting another thread in the dialog object that doesn't end.

Essentially what you need to do is write an ok() and a cancel() method that over-rides the base class.  In those methods, you will need to signal your second thread to quit, wait for it to quit, and then invoke the superclass method to close the dialog.

 
Using ooDialog I try to show a log file of some
kind of traffic via TCPIP. For this I have in main program

     dlgobj = .SnifIL~new
     say dlgobj~start("LoopIL")    -- shows 'a Message'
     dlgobj~execute("SHOWTOP")

If you code what I outlined above, the dialog will close, and when you return from execute(), there will be no more ooRexx threads executing and your main program will end.

What would happen with your current code is that when the dialog ends and returns from execute(), the thread you started running in LoopL is still running and so you do not exit from the main program.

Using just the ok() method as an example.  You need an ok button in your dialog.  Then you need to add a method like this, in pseudo code:

::method ok unguarded

  self~signalLoopLToQuit()

  wait until LoopL() has ended

  return self~ok:super

Now, of course how to signal LoopL() to quit, and getting it to quit, is the hard part.  You will also need a few more details.  You should probably check if LoopL is already ended before you enter into the logic of signalling / waiting for it to end. 
 

Within method 'LoopIL' I use
     lendat = SockRecv(csodes, 'loopin', 2)  /* wait to receive
something from the loop */
in blocking mode.

Having it in blocking mode is the problem in signalling the loop to quit.  What I would typically do is have something I could send through the socket connection that would tell it to end.

If that is not an option, then you need a timeout where you drop out of the blocking and check a flag.

--
Mark Miesfeld