0

I have two custom NativeActivity (Root and Final) with respective ActivityDesigner: enter image description here

In the Root NativeActivity I have:

[ContentProperty("Body")]
[Designer(typeof(RootActivityDesigner))]
public class RootActivity : NativeActivity
{
  public Activity Body { get; set; }

  protected override void Execute(NativeActivityContext context)
  {
    if (this.Body != null)
    {
      context.ScheduleActivity(this.Body);
    }
  }
}

and the Final NativeActivity I have:

[Designer(typeof(FinalActivityDesigner))]
public class FinalActivity : NativeActivity
{
  protected override void Execute(NativeActivityContext context)
  {
    //Do Stuff
  }
}

So when I create a new workflow I drag first RootActivity and than drag other activities inside Root Body and all works fine except FinalActivity that doesn't being execute, so "do stuff" doens't hit.

What is wrong?

I have to call context.ScheduleActivity(this.Body); for FinalActivity too?

Thanks a lot!

Nicola C.
  • 2,717
  • 3
  • 18
  • 25

2 Answers2

1

Where is FinalActivity located in the tree. From the designer it looks like it is part of RootActivity but it's source code doesn't contain references FinalActivity anywhere.

Maurice
  • 27,582
  • 5
  • 49
  • 62
0

I don't know where or what Final is, but you have to schedule it somehow. If RootActivity is the controlling entity, then you might do something like this

public class RootActivity : NativeActivity
{
  public Activity Body { get; set; }
  public Activity Final { get; set; }

  protected override void Execute(NativeActivityContext context)
  {
    if (this.Body != null)
    {
      context.ScheduleActivity(this.Body, OnBodyComplete);
    }
  }
    // callback fired after Body completes execution
    private void OnBodyComplete(NativeActivityContext context, 
                                ActivityInstance completedInstance)
    {
        context.ScheduleActivity(Final);
    }

}
  • I tried to do this, but still doesn't work. On WF Persistance database I found this error: System.ArgumentNullException -Value cannot be null. Parameter name: activity. I have suspect on line " public Activity Final { get; set; } " How WF associate Final with my FinalActivity ? – Nicola C. Mar 15 '12 at 11:13