[Gambas-user] [Gambas Bug Tracker] Bug #960: Cannot get dynamically created SerialPort control events to raise.

bugtracker at ...3416... bugtracker at ...3416...
Fri Jul 1 15:22:20 CEST 2016


http://gambaswiki.org/bugtracker/edit?object=BUG.960&from=L21haW4-

Comment #4 by Tobias BOEGE:

To conclude: the warning in [1] targets cases such as this:
  - you enter an event handler for a read-ready stream (like Process_Read)
  - without reading any data, you call Wait.

Since the stream is still ready to be read, you will immediately re-enter the event handler and so it goes on without doing any work.

Example code:

    Private $h As Process
    
    Public Sub Main()
      $h = Shell "echo" For Read Write As "Process"
    End
    
    Public Sub Process_Read()
      Wait
    End

Calling Wait in an event handler will not always, not even under bad circumstances like many events happening, lead to stack exhaustion. It's primarily a matter of where in the event handler you use it and in which handler. If you read a small amount of data from the process before calling Wait, the number of recursive calls required to consume all the data in the Process stream will be finite and, depending on how much data the process creates, will not exhaust your stack.

Also I'm setting this bug to invalid because we even hit the rare occasion that the solution is explicitly mentioned in the docs :-)

[1] http://gambaswiki.org/wiki/cat/eventloop

Tobias BOEGE changed the state of the bug to: Invalid.






More information about the User mailing list