I have a complicated sequential SP2010 workflow with various paths, loops, different custom forms for submitting/editing/approving tasks, etc. Tasks are set up with the typical - createTask -> While Loop -> onTaskChanged -> completeTask -> deleteTask activity pattern.
Everything has seemed to work out pretty well, with minor issues, but this has me stumped. Basically, if I kick off two workflows and get them onto the same approval step, with the same type task pending, and approve one of the tasks, BOTH workflows pick up the change and complete!
When I debug, I can see from my codebehind that I am calling AlterTask on the task item from one workflow (lets say Inspector approval task for PO#111), and immediately following that, the 'onTaskChanged' event from the OTHER workflow (lets say PO#222) gets hit, followed by the 'onTaskchanged' from THIS workflow (PO#111). The afterproperties from both of these events contain the data from the single alterTask call. Both workflows then continue on, and I am left with two workflow instances, both complete, but one still has an outstanding task and no input from that task.
I'm not really sure what to do. I would assume SharePoint manages the task's relationship to their workflow instances, and I can't work out how the wires are getting crossed here.