How to stop workflow in SharePoint before less than 1 min?

This SharePoint workflow tutorial, we will discuss, how to stop workflow in SharePoint before less than 1 min? I have followed this solution from Hoshang Akreyi blog.

You have a SharePoint designer workflow and you want to stop it for less 1 min. so you can’t do that in SharePoint Designer, the minimum time is 1min.

To create a new feature and start the workflow programmatically, but don’t forget to UNCHECK the CHECKBOX for an automatic start when creating an item in SharePoint designer.

Here we can create a SharePoint feature 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);
break;
}
}
}

So that means with System.Threading.Thread.Sleep(5000); you can stop you workflow for 5 sec.

You may like following SharePoint workflow tutorials:

This SharePoint tutorial, we learned how to stop workflow in SharePoint before less than 1 min?

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>