Skip to main content

Zone Actions

Zone Actions are similar to Event Actions but they're not automatically invoked in the same way as EventActions.

These are normally invoked by MessageTarget methods: the target for SendMessage.

Here's an example from TpSlideShow (edited for brevity):

protected void Access_ActionToTilePacket(ActionToTilePacket sentPacket)                                                                                                            
{                                                                                                                                                                                  
    if (sentPacket.SourceInstance == this)                                                                                                                                         
        return; //avoid recursion.                                                                                                                                                 
    if (!m_AcceptsClicks)                                                                                                                                                          
        return;                                                                                                                                                                    
    if (sentPacket.Delay != 0)                                                                                                                                                     
    {                                                                                                                                                                              
        
        TpLib.DelayedCallback(this,()=>ChangeSlide(SlideIndex == 0,false,false),"DelayATTP_Slideshow", sentPacket.Delay);                                                          
        //note that ZoneActions may not may any attention to 'eMode'.                                                                                                              
        if(m_ZoneAction)                                                                                                                                                           
            m_ZoneAction.Exec(this, this.GetType(), m_ZoneTargetTag, ObjectPacket.EventsPropagationMode.ZoneEvents,"",SlideIndex);                                                 
                                                                                                                                                                                   
    }                                                                                                                                                                              
                                                                                                                                                                           

Why the delay? //why do this? Because the use of DelayedCallback would cause the message to be sent with a new context, after the delay,
//which means that the initial packet is lost as the original message from TpActionToTile would have completed sending
//to its recepient. This can be an issue if a ZoneAction is used which takes the packet and re-sends it to other tiles.
//part of what TpMessaging does is to ensure that the same tile is NOT messaged more than once with the same message.
//The delay means that that can't be ensured (which may or may not matter).