First of all thanks to Hoshang Akreyi
for this post. Thanks Hoshang Akreyi for sharing this post.
In this post we will discuss how to stop workflow in SharePoint before less than 1 min? You can also check out some posts on:
You have a SharePoint designer workflow and you want to stop it for less 1 min. so you cant do that in SharePoint designer, the minimum time is 1min.
So create a new feature and start the workflow programmatically, but don’t forget to UNCHECK the CHECKBOX for automatic start when create an item in SharePoint designer
And in the feature add the below code:
SPWorkflowManager workflowManager = lastItem.Web.Site.WorkflowManager;
SPWorkflowAssociationCollection workflowAssociation = lastItem.ParentList.WorkflowAssociations;
foreach (SPWorkflowAssociation Association in workflowAssociation)
if (Association.Name == "WORKFLOWNAME")
System.Threading.Thread.Sleep(5000); //sleep for 5 second
workflowManager.StartWorkflow(lastItem, Association, Association.AssociationData, true);
So that means with System.Threading.Thread.Sleep(5000); you can stop you workflow for 5 sec.