| 4D v18New signal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | 
    4D v18
 New signal 
         | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| New signal {( description )} -> Function result | ||||||||
| Parameter | Type | Description | ||||||
| description | Text |   | Description for the signal | |||||
| Function result | Object |   | Native object encapsulating the signal | |||||
The New signal command creates a signal object.
A signal is a shared object which can be passed as parameter from a worker or process to another worker or process, so that:
Optionally, in the description parameter you can pass a custom text describing the signal. This text can also be defined after signal creation.
Since the signal object is a shared object (see Shared objects and shared collections), it can also be used to maintain user properties, including the signal.description property, by calling the Use...End use structure.
Returned value
The returned signal object contains the following properties and methods:
| Property | Type | Description | 
| signal.signaled | Boolean | (read-only property) false at signal creation. Becomes true when the signal.trigger( ) method is called. | 
| signal.description | Text | Custom description of the signal, if any. | 
| Method | Description | 
| signal.wait( ) | Wait for the signal (calling process/worker) | 
| signal.trigger( ) | Trigger the signal (called process/worker) | 
Here is a typical example of a worker that sets a signal:
 C_OBJECT($signal)
 $signal:=New signal("This is my first signal")
 
 CALL WORKER("myworker";"doSomething";$signal)
 $signaled:=$signal.wait(1) //wait for 1 second max
 
 If($signaled)
    ALERT("myworker finished the work. Result: "+$signal.myresult)
 Else
    ALERT("myworker has not finished in less than 1s")
 End ifThe "doSomething" method could be like:
 C_OBJECT($1)
  //any processing
  //...
 Use($1)
    $1.myresult:=$processingResult  //return the result
 End use
 $1.trigger() // The work is finished
									signal.description
									
									signal.signaled
									
									signal.trigger( )
									
									signal.wait( )
									
	Product:  4D
	Theme:  Process (Communications)
	Number:  
        1641
        
        
        
	
	Created:  4D v17 R4
	
	
	
	4D Language Reference ( 4D v18)
	
	
	
 Add a comment
Add a comment