SideFX

I have a ASP .NET / WF application that works as follows:

1) The user views the current info in a grid on one screen

2) The user clicks a button and is directed to a summary screen

3) The user clicks approve which rehydrates the associated workflow which updates the database

4) The user is redirected to the first form with the grid

My problem is that step 3 takes longer than step 4, so what is showing up in the grid in step 4 is the old information.

Is there a built-in way for me to handle this problem and allow the page to wait until step 3 is complete



Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

PV17

Hi.

Would ManualWorkflowSchedulerService Class resolve your issue http://msdn2.microsoft.com/en-us/library/system.workflow.runtime.hosting.manualworkflowschedulerservice.aspx

P.





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

SideFX

I am already using that.





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

PV17

Hi.

If you are already using that, why don't you then wait until step 3 is completed before you redirect the user (or I am missing something).

P





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

SideFX

When I resume the workflow it then updates the database, so it is out of my hands. The data gets updated when the workflow reaches that activity, but I'm not prevented from redirecting to another page nor am I going to receive any notification on when the workflow has completed this operation.





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

jdw - MSFT

If you are calling RunWorkflow (i.e. using the ManualWorkflowSchedulerService) that method should not return until the workflow goes idle (meaning that all of the activities have run and the workflow is in a state where it is waiting for more input - timer, message...). Is it possible that there is some other layer in your stack that is making an async call to the asp.net code and allowing your client to be redirected before the RunWorkflow call returns

Thanks,
Joel West
MSFTE - SDE

This posting is provided "AS IS" with no warranties, and confers no rights





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

SideFX

In general, could you tell me how I could troubleshoot this problem Any suggestions





Re: Windows Workflow Foundation Keeping the GUI consistent with a Database updating workflow

SideFX

I think I missed something that you all were trying to explain but just figured it out. If there is a workflow that is idle and waiting for external action, then the following is the code that I had that was returning too early:

bool delivered = RaiseEvent(HRReviewed, workflowGuid, employeeId, groupId, taskId, userName);

if (!delivered) throw new EventDeliveryFailedException("Event Delivery Failed");

Note: UseActiveTimers on the ManualWorkflowSchedulingService is set to "true".

The code above actually worked, but in an asynchronous manner. This is because UseActiveTimers was set to true,

causing the runtime to regularly poll the persistence database for work that needs to be done.

The code below worked synchronously, which is what I wanted to happen:

WorkflowRuntimeManager.Instance.RunWorkflow(workflowGuid);

bool delivered = RaiseEvent(HRReviewed, workflowGuid, employeeId, groupId, taskId, userName);

if (!delivered) throw new EventDeliveryFailedException("Event Delivery Failed");

WorkflowRuntimeManager.Instance.RunWorkflow(workflowGuid);

Note: here I UseActiveTimers is still set to true because, although I am not relying on it for event delivery anymore, I still need it for my Delay Activities.

Can someone please verify that everything I'm saying here is correct