Multitasking

When multitasking in robotc are you able to stop a task within itself? For example, for the code below would this task stop if the sensor touchtest is pressed? Thanks in advance for any help!

task Check()
{
	while( true )
 	{
 		if( SensorValue( TouchTest ) == 1)
 		{
 			SensorValue( LiftEncoder ) = 0;
 			startTask( LiftpController );
 			stopTask( Check );
		}
  	else if( SensorValue( TouchTest ) == 0)
  	{
			motorReq TRLift ] = (-30);
  	 	motorReq TLAndBLLift ] = (-30);
  	 	motorReq BRLift ] = (-30);
  	}
  }
}

If I recall correctly, you are able to stop tasks within themselves.

Okay cool. Thank you!

Yes, a task can stop itself. You can also just return from the task and that will have the same effect.

task Check() {
  while( true ) {
    if( SensorValue( TouchTest ) == 1) {
      SensorValue( LiftEncoder ) = 0;
      startTask( LiftpController );
      return;
    }
    else if( SensorValue( TouchTest ) == 0) {
      motorReq TRLift ] = (-30);
      motorReq TLAndBLLift ] = (-30);
      motorReq BRLift ] = (-30);
    }
  }
}