I needed to retrieve all the running workflows for a list item. I tried SPListItem.Workflows and according to MSDN this should give me what I need. It however doesn’t – I found that it also includes completed workflow instances.
I found that I can use the SPWorkflowManager.GetItemActiveWorkflows() method instead to achieve what I needed.
The MSDN documentation for SPListItem.Workflows says:
Gets the collection of the workflow objects that represent instances of the item workflows that are currently running, but does not get the workflow associations.
The MSDN documentation for SPWorkflowManager.GetItemActiveWorkflows() says:
Returns a collection of the workflow instances currently running on the specified list item.
One would expect that they would give the same results – it however seems that the former doesn’t work as documented.