[Gambas-user] Receiving events on an array of process objects

Tobias Boege taboege at gmail.com
Fri May 25 12:27:09 CEST 2018


On Thu, 24 May 2018, Phil Underhill wrote:
> Hi all.
> 
> Given the following example code...
> 
> ​#####
> 
>> Public myProcesses As New Object[]
> 
> Public Sub Button1_Click()
>   Dim myProcess As Process
>   myProcess = Exec ["/usr/bin/glxgears"] As "myProcess"
>   myProcesses.Push(myProcess)
> End
> #####
> 
> ...is it possible for me receive events from this array of Process objects?
> Any pointers much appreciated.
> 

In Gambas, objects raise events under an event name and their observer(s)
intercept them. You are creating

  myProcess = Exec [...] As "myProcess"

The 'As "myProcess"' clause declares the event name of the myProcess object.
The default observer is the object in which this code is run. For more
details, see [1].

By creating many different processes with the same event name, you can treat
events of many objects with a single event handler. The special variable LAST
is used during event handlers to indicate which Process raised the event.

So, did you try the code you posted above? It should do exactly what you
want (that's at least the best interpretation I can think of for "receiving
events from an array of Process objects"). Assuming of course, that you
have declared event handlers Public Sub myProcess_Read() and such.

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/object-model

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list