You are viewing limited content. For full access, please sign in.

Question

Question

Delay Feature - Workflow - Delay by Seconds

asked on June 17, 2014

Hi Folks,

 

I have a few workflows where the user experience would be greatly improved (ie.error messesages in Web Access), by the ability to delay a workflow by seconds (as opposed to minutes).

 

Any idea how this is possible? 

 

Doug

 

5 0

Replies

replied on June 17, 2014 Show version history

I used a script for a shorter delay.   Add "System.Threading" as a reference to the script.


Namespace WorkflowActivity.Scripting.Script_ThreadSleep
    '''<summary>
    '''Provides one or more methods that can be run when the workflow scripting activity is performed.
    '''</summary>
    Public Class ThreadSleep
        Inherits ScriptClass90
        '''<summary>
        '''This method is run when the activity is performed.
        '''</summary>
        Protected Overrides Sub Execute()
            'Write your code here.
            System.Threading.Thread.Sleep(20000)

        End Sub
    End Class
End Namespace

The 20000 is milliseconds, so you can adjust that accordingly.

1 0
replied on June 17, 2014

Please don't do that, it will cause performance issues under load.

0 0
replied on June 17, 2014

We were having issues with an integration storing documents that we need workflow to trigger for, but workflow was locking the entry prior to all of the information on the document being written (causing the integration to be unable to finish writing all of the information).  So, the first step in the workflow is to wait 5 seconds to make sure it was complete.

 

0 0
replied on June 17, 2014

It sounds like your integration is either releasing the creation lock prematurely or not locking the document when it makes changes.

 

The problem with the sleep is that Windows Workflow Foundation only has a limited number of slots for actively running workflows. An activity is considered actively running for as long as it does work (for ex, Move Entry would be actively running while it move the document, but Wait for Entry Change would only be actively running when it evaluates the condition). This is not normally a problem since the activities are expected to execute very fast. A sleeping thread would be considered actively running for the entire duration of the sleep, so you are holding off a slot for the entire duration. Under load, this could easily create a backlog of instances waiting for a free slot to run in.

3 0
replied on June 17, 2014

Doug,

 

Can you tell us more about why you need a delay under a minute?

0 0
replied on June 17, 2014

We have a piece of meta-data triggering a workflow (Accept Application). Once the application is accepted, it moves the document to another folder. In Web Access if the document viewer is open, it will kick out an error that the document has mowed. This confuses our users.

0 0
replied on June 17, 2014

Maybe you can do a custom query that you know will take a very long time but should never fail, then set the custom timeout to the amount of seconds you want it to timeout at, then you have your delay.

0 1
You are not allowed to follow up in this post.

Sign in to reply to this post.