Code:
public void CompleteTask(Guid taskId)
{
SetStateTaskRequest tr = new SetStateTaskRequest();
tr.EntityId = taskId;
tr.TaskState = new TaskState();
tr.TaskState = TaskState.Completed;
tr.TaskStatus = -1 ; // Set this field to -1 to have the platform set the appropriate value
service.Execute(tr);
}
Unfortunately for some unknown reason; completing the task using the above code will cause the workflow (a Sales Process workflow was tested) to end.