views:

66

answers:

0

I am creating a state machine workflow using .NET 3.5 in a SharePoint context (though I think the same issue would arise in non-SharePoint context).

I needed to implement recurring reminders and followed the pattern discussed here.

In one of my states I have two eventdriven activities, holding respectively

  1. an OnTaskChanged activity and other subsequent activities
  2. a Delay activity and other subsequent activities

If the user completes the task (thereby triggering OnTaskChanged) after the Delay time is up but before the timer service has woken up the workflow, which happens sometimes since the timer service only checks every 5 minutes, my flow breaks - the workflow fails to enter to the next state I'd intended - because I believe the following happens:

  • When the OnTaskChangedEvent is fired, the workflow becomes aware that a Delay threshhold was exceeded and yet remains unprocessed, and so it fires that Delay event in retrospect.
  • So although OnTaskChanged was the event I'm interested in pursuing, the execution seems to be "hijacked" by the Delay event and execution of OnTaskChanged does not complete properly.

This doesn't happen when the timer service detects and processes the Delay timeout because then I guess there is no unprocessed event in the queue when OnTaskChanged fires.

Is there a way to stop the Delay event firing if the OnTaskChanged event fires? (since the Delay is obsolete in such a circumstance?)