Andy Ho

Dear all,

I have a StateMachine like this:


----- Event Driven


----------SetState (to state2)

State 2

----- Event Driven


----------SetState (to state3)

State 3

----- Event Driven


----------SetState (to state4)

State 4 (Final State)

And my host application do this:

1) Implemented the SQLPersistenceService (no tracking yet), set unloadonidled to 5 seconds. Added Handler for both workflow idle and persisted events.

2) The use click a button to raise an event to start a new workflow instance (State 1). By default, State1 will prompt an alert then goto State2 (become idle). The host actually unload this idled workflow and the onpersisted event fired correctly and automatically. Everything seems fine.

3) Then I used the PersistenceService.GetAllWorkflows function to return and list all persisted workflows and let the user to choose one of them, then clicked a submit button to fire an event to activate State2.

4) I added a messagebox alert at state 2 so I'm sure that the runtime have processed State 2.

5) After that the workflow will goto State3 and become idle again, but this time, no persisted event has been fired although the onidled event has been fired correctly Anyone knows Why

(But if I click the button several times, sometimes the persisted event will be fired correctly.)

The way that I fired the event is:

RaiseEvent FireState2(Nothing, New StateTwoEventArgs(WFGUID, "Hello"))

Another question is how to retrieve workflow properties/values before the workflow completion (cos can't use the e.outputparameters expression when the workflow is not yet completed.)

Please help.



Re: Windows Workflow Foundation Workflow not Persisted

Andy Ho


Some new findings to this thread, if I've called the StateMachineWorkflowInstance to get the CurrentStateName, I must unload the workflowinstance from memory with the Unload method before raising the event, then everything will work fine.

Any idea

Andy Ho

Re: Windows Workflow Foundation Workflow not Persisted

Tom Lake - MSFT

What you tried this with the release version of the product To retreive workflow properties before the workflow completes you need to use tracking or have an event driven on the root state machine that when it receives the event it sends back the data with a call external method activity.