locked
Strange Behavior with WhileActivity... RRS feed

  • Question

  • Hi, I'm back with a new question... because I'm experiencing a strange behavior, with my custom activities. Let me start from the begining... I've made a bunch of custom activities, all extending a custom ActivityBase class. Those are a StartActivity, EndActivity, StepActivity and a ChoiceActivity which has to present a set of choices and accept one of them. The base activities in all my custom activities are CallExternalMethod and HandleExternalEvent activities. Each custom activity begins with a WhileActivity in which cycle while activity resources are missing: it requests resource assignment by calling an external method and whaits for an event telling the assignment has been made. If all resources are set whe while procedes on a next CallExternalMethod asking to review the Choices and respond by selecting one by rising an External event. Ok, now I'm able to combine those activities in some complex Workflows. Everything works fine with my ChoiceActivity unless I put it inside a whileActivity: in this case somehow the entire activity is bypassed, without exceptions.
    Can someone explain to me why this behavior? I'm wondering if it could be some mess up with the correlation tokens I've defined in the ChoiceActivity: (there is a correlation token called "CC" bound to all activities inside my ChoiceActivity; with OwnerActivityName set to the sequenceActivity in the WhileActivity of resource setting, and set to ChoiceActivity in the activities handling the choice process).
    I hope I've been sufficiently confusing in my explanation Surprise) ... and I'll really
    appreciate if someone could find me a reason and of course a workaround...

    Thanks
    Alessandro
    Monday, October 20, 2008 9:03 AM

Answers

  • Every time the WhileActivity runs the activities within the while loop are re-created.  Another way to put it is that state from within a loop is only valid for that loop.  Try moving the bool property to somewhere outside of the loop.

     

    Thanks,

    Joel

     

    Tuesday, October 28, 2008 5:39 PM

All replies

  • Oh, never mind... Finally I found that there was an error in the While condition... sigh! I'm sorry!

    Alessandro
    Monday, October 20, 2008 4:14 PM
  • Oh yes, I know I sound like a pain in the ***, but I finally figured out what's the problem in the strange behavior of my workflow execution. Is really strange, or maybe I didn't understand haw things works...
    Ok, let me explain the scenario: I have a simple workflow with a WhileActivity which contains a custom activity called StepWithSignActivity. This Activity is a Sequential Activity which has a Boolean property Sign by default set to false and CallExternalActivity that asks the user to Sign and HandleExternalEventActivity that waits for sign event and sets the Sign property with the value passes in the EventArgs. The whileActivity checks the Sign property of the StepWithSignActivity and repeats while Sign is false. The thing I can't explain is why if I set the Sign Property to true (and I can check it in the method where i set the property) but when the whileActivity Checks the value it seams it remains false. Maybe the while resets the contents before eveluate it?
    The workflow is an xoml and the while check is a declarative rule condition that sounds like this:

    ! ( (StepWithSignActivity)this.GetActivityByName("NameOfTheSignActivity")).Sign

    It looks like the Sign remains always false!!!
    Is this a correct behavior? If yes how can I evaluate the activity inside the While?
    Thanks
    Alessandro

    Tuesday, October 21, 2008 3:21 PM
  • Every time the WhileActivity runs the activities within the while loop are re-created.  Another way to put it is that state from within a loop is only valid for that loop.  Try moving the bool property to somewhere outside of the loop.

     

    Thanks,

    Joel

     

    Tuesday, October 28, 2008 5:39 PM