Task Is Locked By A Running Workflow

Recently i uploaded my custom form in editform.aspx and when i try to edit it here is the error that i got.  
This happens because workflow that i created is just designed to create task and not update the task that has already been created. Thanks to this blog. Using this code in the custom web part will solve the problem. Use it before updating the task.

This is to make sure that the workflow version number is always equals to 1 before updated.