Listening for Activity Closed Events

I created a custom sequential activity. I would like this activity to listen for it's children's closed events. However, other than the thing I want to happen when the child closes, I do not want to change anything about how a sequential workflow exececutes. Is there an easy way to do this? I would prefer not to have to override the entire execute method in order to listen to the close events.

Amanda

[407 byte] By [AmandaJamin] at [2007-12-22]
# 1
You could derive from SequenceActivity - override Execute - subscribe to the closed event of all the activities in the Activities collection and then call base.Execute.
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
I tried that with the following code

for (int child = 0; child < this.EnabledActivities.Count; child++)
{
Activity branch = this.EnabledActivities[child] as Activity;

if (null != branch)
{
// Now register a callback to be notified when the child has closed
branch.RegisterForStatusChange(Activity.ClosedEvent, this);

}
}

base.execute(executionContext);

where my Activity also implements the listener interface, but it seems that only my first item in my workflow gets executed.

AmandaJamin at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Amanda - I believe you want to subscribe to the Activity.Closed event directly -rather than use the IActivityEventListen
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
That fixed it. Thank you. Is there a particular reason one way works and the other doesn't?

Amanda

AmandaJamin at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
IActivityEvents requires that the composite activity subscribe as each activity executes - since you aren't controlling the execution - you can't do that in this case.
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified