Nicola C.
Nicola C.

Reputation: 2947

Nested ActivityDesigner execution

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!

Upvotes: 0

Views: 161

Answers (2)

user1228
user1228

Reputation:

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);
    }

}

Upvotes: 0

Maurice
Maurice

Reputation: 27632

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.

Upvotes: 1

Related Questions