how to get the last state of the wf instance RRS feed

  • Question

  • Hello,
        I am working with the Stopwatch40 flow chart sample. I've added some code to save the instance to the sqlworkflow store (persistence db).  Can you pelase tell me how to get the Last State of the wf instance?


    Wednesday, November 25, 2009 7:00 PM


  • Are you referring to the StopWatch implemented using Flowchart + Pick (%SamplesRoot%\WF\Scenarios\StateMachinePick)?

    If this is the case, Flowchart does not have automatic support for storing the state. The state is stored in a variable (currentState), but you can't query it while the activity is executing. That said, you can save the current state during persistence and query it. To do this, you will need to add a PersistenceParticipant (%SamplesRoot%\WF\Basic\Persistence\PersistenceParticipant) that saves the content of the currentState variable. To make the variable accessible during persistence, you will need to mark it as "Mapped" (you can do this by going to the properties of the variable, clicking on Modifiers, and checking Mapped). To save the currentState value, you may be interested in the using "promoted values" feature (%SamplesRoot%\WF\Basic\Persistence\SQLStoreExtensibility).

    More information on the above mentioned samples here http://msdn.microsoft.com/en-us/library/dd807502(VS.100).aspx and http://msdn.microsoft.com/en-us/library/ee622979(VS.100).aspx.

    Leon Welicki
    Program Manager, WF

    Tuesday, December 1, 2009 6:36 PM