Click or drag to resize

ControllerMastershipChanged Event

Occurs when MasterShip has changed.

Namespace:  ABB.Robotics.Controllers
Assembly:  ABB.Robotics.Controllers (in ABB.Robotics.Controllers.dll) Version: 6.5.129.0
Syntax
C#
public event MastershipChangedEventHandler MastershipChanged

Value

Type: ABB.Robotics.ControllersMastershipChangedEventHandler
Exceptions
ExceptionCondition
GeneralExceptionA General Exception has occurred.
Remarks
Any subscriber that wants to update their UI as a response to the event has to redirect the execution to the UI-thread, using the Invoke method. Note: You should not switch to the UI-thread if you do not need to update the UI, as a thread switch has an impact on performance.
Examples
This example creates a Controller instance and sets up a subscription to the MastershipChanged event. The event handler redirects execution to another event handler, executing on the UI-thread (see Invoke method on TpsControl). The latter retrieves further information about the current master.
bool ITpsViewSetup.Install(object sender,object data)
{
    bool result = true;
    try
    {
        // Create Controller
        c = new Controller();

        c.MastershipChanged += 
            new MastershipChangedEventHandler(c_MastershipChanged);
    }
    catch (System.Exception ee)
    {
        result = false;
    }

    return result;
}

// Event handler
private void c_MastershipChanged(object sender, MastershipChangedEventArgs e)
{
    // Redirect execution to UI-thread
    this.Invoke(new EventHandler(UpdateListbox),sender,e);
}

// Executes on UI-thread
private void UpdateListbox(object sender, System.EventArgs e)
{
    MastershipChangedEventArgs args = e as MastershipChangedEventArgs;
    if (args != null)
    {
       if (args.Status == MastershipStatus.Remote)
       {
           Mastership ms = c.GetCurrentMaster(args.Resource);
       }
     }
}
See Also