Statements: postsignal

The postsignal statement posts a signal to a slot method.


Form 1:


Form 2:



The postsignal statement records the slot method determined by the slot-expression for later invocation. The recorded slot methods are invoked immediately before the impending screen update begins but after all pending user inputs and events have been processed. Thus, unlike its counterpart signal, the postsignal statement doesn't wait for the slot method completion. If the slot-expression results in the value null, then no slot method is recorded. For example:

var slot s1 = someObject.OnShowMenu; var slot s2 = null; // Record slot method 'OnShowMenu' of 'someObject' for later execution postsignal s1; // The expressions results in 'null'. Nothing happens. postsignal s2;

Per default, when the slot method is invoked, the identity of the sender object (see this variable) is passed on to the slot method in the hidden parameter sender. Thereupon the implementation of the slot method can evaluate or even interact with the sending object. In its second form, the postsignal statement allows you to explicitly specify in the sender-expression another object to be passed on instead of the actual sender object, even a null object. It permits the sender to feign a foreign identity against the slot method. For example, you can implement a button able to post signals with the identity of its superior component:

var slot theSlot = ...; // Send the signal with the identity of the superior GUI component. postsignal theSlot, Owner;

All recorded slot methods are invoked strictly in the order, in which the corresponding postsignal statements have been executed. When trying to record the same slot method twice, the postsignal statement invalidates (removes) the old entry first before the slot method is newly registered. For example:

// The three slot methods are recorded and will be invoked in the order: // 'SlotMethod1', 'SlotMethod2' and 'SlotMethod3'. postsignal someObject.SlotMethod1; postsignal someObject.SlotMethod2; postsignal someObject.SlotMethod3; // With this operation the order changes to: // 'SlotMethod2', 'SlotMethod3' and 'SlotMethod1'. Moreover, 'SlotMethod1' // will be invoked with 'Owner' object as the sender. The other methods // are invoked with 'this' as sender. postsignal someObject.SlotMethod1, Owner;


A repeated attempt to postsignal again the signal being currently in process is detected and suppressed automatically in order to avoid endless signal delivery. In such case the Log window or the console, if any available in the target device, displays a warning saying that the signal could not be posted again. In any case it is prudent to analyze and understand the reason of the warning. This can be a symptom of an eventual logical error in your implementation.

You should also be careful, when implementing slot methods sending postsignal to each other. This may lead the application to stuck in an endless signal delivery state. Unlike the above described warning, this is not detected automatically.

Please note, slot methods can be invoked also by using the signal and the idlesignal statements.