TaskCancelRoutine Method |
Namespace: ABB.Robotics.Controllers.RapidDomain
public void CancelRoutine()
If the "Cancel Routine" button is pressed the CallRoutine(String) request is canceled, restoring the program pointer to its location outside of the routine.
using ABB.Robotics; using ABB.Robotics.Controllers; using ABB.Robotics.Controllers.RapidDomain; ... Controller c = new Controller(); Task[] allTasks = c.Rapid.GetTasks(); Task tRob1 = allTasks[0]; ... // this is the event handler of the subscription set up when CallRoutine was called void tRob1_ExecutionStateChanged(object sender, ExecutionStateChangedEventArgs e) { try { //check if execution has been stopped in a routine started by CallRoutine if (tRob1.ExecutionState == ExecutionState.Stopped && tRob1.ExecutionType == ExecutionType.UserRoutine) { //Invoke to force execution to the GUI thread this.Invoke(new EventHandler(UpdateGUI), sender, e); } } catch (System.Exception) { // Exception handling ... } } private void UpdateGUI(object sender, EventArgs e) { try { btnCancelRout.Visible = true; btnStartRout.Visible = false; } catch (System.Exception ex) { // Exception handling ... } } private void btnCancelRout_Click(object sender, EventArgs e) { try { tRob1.CancelRoutine(); btnCancelRout.Visible = false; btnStartRout.Visible = true; } catch (System.Exception ex) { // Exception handling ... } }