When trying to update a workflow task item in code, you may get the error “This task is currently locked by a running workflow and cannot be edited.”
This error gets thrown because the ows_WorkflowVersion of the task list item has been set to 512.
There may be a good reason it’s set to locked (i.e. currently being updated) but it you really really want to still update the task, you can override the flag.
task[SPBuiltInFieldId.Title] = "Just update me"; task[SPBuiltInFieldId.WorkflowVersion] = 1; task.SystemUpdate(false);
Been working fine so far for me, but there may be unforeseen consequences of ignoring the locked flag…
May also be useful to unlock a locked workflow task due to errors.